From de33dca28cb30e916e383131ce110858b21877d2 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Wed, 20 Nov 2019 23:36:21 +0100 Subject: use calloc to avoid uninitialized memory when the file is trunctated --- atxec.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/atxec.c b/atxec.c index f1bdf7e..b40fd74 100755 --- a/atxec.c +++ b/atxec.c @@ -102,7 +102,7 @@ file_splice(char *file) fstat(fileno(f), &st); - s = malloc(st.st_size + 1); + s = calloc(1, st.st_size + 1); if (!s) { fclose(f); return; @@ -110,8 +110,6 @@ file_splice(char *file) fread(s, 1, st.st_size, f); fclose(f); - s[st.st_size] = 0; - arg_splice(s); /* leak string, args points into it! */ -- cgit 1.4.1