forked from osmocom/wireshark
Fix allocation of option bocks in pcapng_read().
We don't need to allocate an WTAP_OPTION_BLOCK_IF_DESCR option block; don't use the value we allocated. We must not allocate an WTAP_OPTION_BLOCK_IF_STATS option block until we need it, as we may have to allocate *more than one* of them here! The old code would reuse the same block, adding it more than once, causing a "freeing already freed data"/"freeing non-allocated data" error on some platforms. Change-Id: I8582627c1f5deecfd4f6490dcdf8c31ee3809d12 Reviewed-on: https://code.wireshark.org/review/14130 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
40fe88daf4
commit
6257b65481
|
@ -2560,8 +2560,8 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
|||
{
|
||||
pcapng_t *pcapng = (pcapng_t *)wth->priv;
|
||||
wtapng_block_t wblock;
|
||||
wtap_optionblock_t wtapng_if_descr = wtap_optionblock_create(WTAP_OPTION_BLOCK_IF_DESCR);
|
||||
wtap_optionblock_t if_stats = wtap_optionblock_create(WTAP_OPTION_BLOCK_IF_STATS);
|
||||
wtap_optionblock_t wtapng_if_descr;
|
||||
wtap_optionblock_t if_stats;
|
||||
wtapng_if_stats_mandatory_t *if_stats_mand_block, *if_stats_mand;
|
||||
wtapng_if_descr_mandatory_t *wtapng_if_descr_mand;
|
||||
|
||||
|
@ -2626,6 +2626,7 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
|||
wtapng_if_descr_mand->interface_statistics = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
|
||||
}
|
||||
|
||||
if_stats = wtap_optionblock_create(WTAP_OPTION_BLOCK_IF_STATS);
|
||||
if_stats_mand = (wtapng_if_stats_mandatory_t*)wtap_optionblock_get_mandatory_data(if_stats);
|
||||
if_stats_mand->interface_id = if_stats_mand_block->interface_id;
|
||||
if_stats_mand->ts_high = if_stats_mand_block->ts_high;
|
||||
|
|
Loading…
Reference in New Issue