properly zero-terminate input buffer - Bug #605

http://bugs.mariadb.com/show_bug.cgi?id=605
This commit is contained in:
Hartmut Holzgraefe
2014-11-02 14:18:22 +01:00
parent ff30e2f206
commit d23cb087ec

View File

@ -51,12 +51,13 @@ int main(int argc, char** argv)
fsz = lseek(fdin,0,SEEK_END);
lseek(fdin,0,SEEK_SET);
if(!(buffer = malloc(sizeof(char)*fsz))){
if(!(buffer = malloc(sizeof(char)*fsz + 1))){
printf("Error: Failed to allocate memory.");
return 1;
}
read(fdin,buffer,fsz);
buffer[fsz] = '\0';