From d23cb087ec0ab13ca1ac6356ce8b69f37d30c1b9 Mon Sep 17 00:00:00 2001 From: Hartmut Holzgraefe Date: Sun, 2 Nov 2014 14:18:22 +0100 Subject: [PATCH] properly zero-terminate input buffer - Bug #605 http://bugs.mariadb.com/show_bug.cgi?id=605 --- query_classifier/test/canonical_tests/canonizer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/query_classifier/test/canonical_tests/canonizer.c b/query_classifier/test/canonical_tests/canonizer.c index b9b17222f..107ccb670 100644 --- a/query_classifier/test/canonical_tests/canonizer.c +++ b/query_classifier/test/canonical_tests/canonizer.c @@ -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';