diff options
author | Guy Harris <gharris@sonic.net> | 2021-08-29 19:12:13 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-08-29 19:12:13 -0700 |
commit | 3cb6403a4caecd763e8e9a45a81160aac0644515 (patch) | |
tree | 3a321d42c17675aee99bcde1a6e59b5f9f146a91 /file.c | |
parent | eb2037fda4e3310c00ed4afb73195f3c4a9f27c9 (diff) |
wiretap: always allocate a block for a record.
Without that, you could add a comment to a record in a file format the
reading code for which doesn't allocate blocks, but the comment doesn't
get saved, as there's no block in which to save the comment option.
This simplifies some code paths, as we're either using the record's
modified block or we're using the block as read from the file, there's
no third possibility.
If we attempt to read a record, and we get an error, and a block was
allocated for the record, unreference it, so the individual file readers
don't have to worry about it.
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -4004,13 +4004,12 @@ cf_get_packet_block(capture_file *cf, const frame_data *fd) /* If this block has been modified, fetch the modified version */ if (fd->has_modified_block) return wtap_block_ref(cap_file_provider_get_modified_block(&cf->provider, fd)); - - /* fetch phdr block */ - if (fd->has_phdr_block) { + else { wtap_rec rec; /* Record metadata */ Buffer buf; /* Record data */ wtap_block_t block; + /* fetch record block */ wtap_rec_init(&rec); ws_buffer_init(&buf, 1514); @@ -4024,7 +4023,6 @@ cf_get_packet_block(capture_file *cf, const frame_data *fd) ws_buffer_free(&buf); return block; } - return NULL; } /* @@ -4767,7 +4765,6 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format, fdata = frame_data_sequence_find(cf->provider.frames, framenum); // XXX: This also ignores non-comment options like verdict - fdata->has_phdr_block = FALSE; fdata->has_modified_block = FALSE; } |