[PATCH] Fix a crash on CSV import

Miika Turkia miika.turkia at gmail.com
Sun Dec 7 11:36:54 PST 2014


Seems that there was not enough space reserved for the whole mem buffer
when adding XML tags around CSV file. When unlucky, the metadata of
memory allocation was overwritten.

Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
 file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/file.c b/file.c
index d733613..d856610 100644
--- a/file.c
+++ b/file.c
@@ -116,7 +116,7 @@ static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, cons
 	 *
 	 * Tag markers take: strlen("<></>") = 5
 	 */
-	buf = realloc(mem->buffer, mem->size + 5 + strlen(tag) * 2);
+	buf = realloc(mem->buffer, mem->size + 6 + strlen(tag) * 2);
 	if (buf != NULL) {
 		char *starttag = NULL;
 		char *endtag = NULL;
-- 
1.9.1



More information about the subsurface mailing list