diff options
| author | jakob <jakob@memeware.net> | 2017-05-11 20:18:08 -0400 |
|---|---|---|
| committer | jakob <jakob@memeware.net> | 2017-05-11 20:18:08 -0400 |
| commit | 986a9e120d79f625cbd7b4c59ccfd479a6a149ec (patch) | |
| tree | d01d04bf547d15856a1471af7312b10c9c47ff53 /src/main.c | |
| parent | 93919335b1cff88127cb1d6e2ad1762dd7bf353e (diff) | |
Reimplemented table dumping functions to operate on streams instead of file pointers
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -207,13 +207,20 @@ static void create_archive(char **paths, int argc, struct params p) { return; } - struct header *h = create_header(); - struct table_entry *root = calloc(sizeof(struct table_entry), 1), *cur; + struct header *h = create_header(); + struct table_entry *root = calloc(sizeof(struct table_entry), 1), *cur; + struct stream *table = stream_new(1); dump_header(fp, h); for (int i = 1; i < argc - p.vararg_index; i++) { cur = add_file(root, paths[i]); } - dump_table(fp, root); + dump_table(table, root); + /* FIXME: table->len steps the bounds of the table and leaks memory + which can potentially be a huge security risk. Either fix the + functionality that expands the stream in memory, or get a table + size. */ + stream_seek(table, 0, SEEK_SET); + stream_dump(fp, table, table->len); } |