From d57bcd048411b1d1cccf3522d6fd95c568efbf1d Mon Sep 17 00:00:00 2001 From: Allanis <allanis@saracraft.net> Date: Fri, 15 Feb 2013 20:48:55 +0000 Subject: [PATCH] [Fix] Slight change to pack file to append '\0' to string. --- src/pack.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pack.c b/src/pack.c index 5c51e11..4899bd8 100644 --- a/src/pack.c +++ b/src/pack.c @@ -252,9 +252,9 @@ void* pack_readfile(const char* packfile, const char* filename, uint32_t* filesi } DEBUG("Opened file '%s' from '%s'", filename, packfile); - // Read the entire thing. + // Read the entire file. size = file->end - file->start; - buf = malloc(size); + buf = malloc(size+1); if((bytes = pack_read(file, buf, size)) != size) { ERR("Reading '%s' from packfile '%s'. Expected %d bytes got %d bytes", filename, packfile, size, bytes); free(buf); @@ -262,6 +262,7 @@ void* pack_readfile(const char* packfile, const char* filename, uint32_t* filesi return NULL; } DEBUG("Read %d bytes from '%s'", bytes, filename); + memset(buf+size, '\0', 1); // Append size '\0' for it to validate as a string. // Check the md5. md5_state_t md5;