zipper: Don't assume argument file ends with '\n'
Resolves #10350.
Testing Done:
```console
$ touch foo bar
$ echo foo > args.txt
$ echo -n bar >> args.txt
$ valgrind zipper Cc foo.zip @args.txt
```
Closes #10351.
PiperOrigin-RevId: 283511704
diff --git a/third_party/ijar/zip_main.cc b/third_party/ijar/zip_main.cc
index eac095e..b375da3 100644
--- a/third_party/ijar/zip_main.cc
+++ b/third_party/ijar/zip_main.cc
@@ -251,11 +251,12 @@
}
size_t sizeof_array = sizeof(char *) * (nb_entries + 1);
- void *result = malloc(sizeof_array + file_stat.total_size);
+ void *result = malloc(sizeof_array + file_stat.total_size + 1);
// copy the content
char **filelist = static_cast<char **>(result);
char *content = static_cast<char *>(result) + sizeof_array;
memcpy(content, data, file_stat.total_size);
+ content[file_stat.total_size] = '\0';
free(data);
// Create the corresponding array
int j = 1;