From 1e59465c8abdce055fd9cd3b66ea4547c88c688d Mon Sep 17 00:00:00 2001 From: tpearson Date: Thu, 22 Sep 2011 00:49:06 +0000 Subject: Fix smartauthmon memory corruption due to undersized buffer git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/smartcardauth@1254885 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/smartauthmon.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/smartauthmon.cpp') diff --git a/src/smartauthmon.cpp b/src/smartauthmon.cpp index 0c353ab..3c5dd98 100644 --- a/src/smartauthmon.cpp +++ b/src/smartauthmon.cpp @@ -81,11 +81,11 @@ TQString readfile(const char * filename) { fseek(fp,0,SEEK_END); // Seek to end len=ftell(fp); // Get position at end (length) fseek(fp,0,SEEK_SET); // Seek to beginning - buf=(char *)malloc(len); // Malloc the buffer + buf=(char *)malloc(len+1); // Malloc the buffer fread(buf,len,1,fp); // Read file fclose(fp); buf[len]=0; - TQString contents = TQString(buf); + TQString contents(buf); free(buf); // Free the buffer return contents; } -- cgit v1.2.1