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
v3.5.13-sru
tpearson 13 years ago
parent 38f40eb14d
commit 1e59465c8a

@ -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;
}

Loading…
Cancel
Save