diff options
author | Leah Neukirchen <leah@vuxu.org> | 2019-11-20 23:36:21 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2019-11-20 23:38:10 +0100 |
commit | de33dca28cb30e916e383131ce110858b21877d2 (patch) | |
tree | eebbd96971b67541d5dcf21d6892afc0d078c876 | |
parent | e482f75e7d11ca64a67efe5c8bb757ff983ac4af (diff) | |
download | atxec-de33dca28cb30e916e383131ce110858b21877d2.tar.gz atxec-de33dca28cb30e916e383131ce110858b21877d2.tar.xz atxec-de33dca28cb30e916e383131ce110858b21877d2.zip |
use calloc to avoid uninitialized memory when the file is trunctated
-rwxr-xr-x | atxec.c | 4 |
1 files changed, 1 insertions, 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! */ |