diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-07-15 01:31:16 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-07-15 08:31:55 +0000 |
commit | 996dcc038dea197924285a6717b522a57f95fd65 (patch) | |
tree | 064ca576e610eb4ce34f290235dcd1d719368a8b /wiretap/pcapng.c | |
parent | ced207150542f59f395fc4052d8a7cdfba67effa (diff) | |
download | wireshark-996dcc038dea197924285a6717b522a57f95fd65.tar.gz |
Do a deep copy in wtap_block_add_custom_option().
That way, we don't have to worry about multiple instances of an option
pointing to the same data. and having to worry about freeing data that's
pointed to by another instance.
Change-Id: I3470a9eebf346023713fd0d6ff2451d727c25089
Reviewed-on: https://code.wireshark.org/review/16471
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/pcapng.c')
-rw-r--r-- | wiretap/pcapng.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c index a46d976197..62c730ca3e 100644 --- a/wiretap/pcapng.c +++ b/wiretap/pcapng.c @@ -885,11 +885,11 @@ pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh, pcapng_debug("pcapng_read_if_descr_block: if_filter_str %s oh.option_length %u", if_filter.if_filter_str, oh.option_length); } else if (option_content[0] == 1) { if_filter.bpf_filter_len = oh.option_length-1; - if_filter.if_filter_bpf_bytes = (gchar *)g_malloc(oh.option_length-1); - memcpy(if_filter.if_filter_bpf_bytes, (char *)option_content+1, oh.option_length-1); + if_filter.if_filter_bpf_bytes = (guint8 *)option_content+1; } /* Fails with multiple options; we silently ignore the failure */ wtap_block_add_custom_option(wblock->block, OPT_IDB_FILTER, &if_filter, sizeof if_filter); + g_free(if_filter.if_filter_str); } else { pcapng_debug("pcapng_read_if_descr_block: if_filter length %u seems strange", oh.option_length); } |