diff options
author | Dario Lombardo <lomato@gmail.com> | 2021-03-23 16:41:54 +0100 |
---|---|---|
committer | Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org> | 2021-03-25 09:38:10 +0000 |
commit | ea929d6401351916e0abca7429979eee9c47d3f2 (patch) | |
tree | 522492a802e608e8049fa5a3586477053002bce0 /wiretap | |
parent | e6df13076281a704e9dd1aa8c2afe3e7dce015e3 (diff) |
wsutils: add local implementation of g_memdup2.
g_memdup() was deprecated and replaced with g_memdup2() in GLib 2.68,
we provide our own copy of g_memdup2() for older GLib versions.
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/erf.c | 3 | ||||
-rw-r--r-- | wiretap/k12.c | 5 | ||||
-rw-r--r-- | wiretap/pcapng.c | 3 | ||||
-rw-r--r-- | wiretap/wtap_opttypes.c | 6 |
4 files changed, 11 insertions, 6 deletions
diff --git a/wiretap/erf.c b/wiretap/erf.c index 878cfc1c3b..672661532a 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -30,6 +30,7 @@ #include <wsutil/crc32.h> #include <wsutil/strtoi.h> +#include <wsutil/glib-compat.h> #include "wtap-int.h" #include "file_wrappers.h" @@ -3253,7 +3254,7 @@ static int populate_summary_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo_h * before the interface information, as we associate them to interface * data. */ - post_list = g_list_append(post_list, g_memdup(&state, sizeof(struct erf_meta_read_state))); + post_list = g_list_append(post_list, g_memdup2(&state, sizeof(struct erf_meta_read_state))); break; case ERF_META_SECTION_SOURCE: case ERF_META_SECTION_DNS: diff --git a/wiretap/k12.c b/wiretap/k12.c index ece5b697db..d9ee211c92 100644 --- a/wiretap/k12.c +++ b/wiretap/k12.c @@ -21,6 +21,7 @@ #include "k12.h" #include <wsutil/str_util.h> +#include <wsutil/glib-compat.h> /* * See @@ -1060,8 +1061,8 @@ wtap_open_return_val k12_open(wtap *wth, int *err, gchar **err_info) { g_free(rec); return WTAP_OPEN_ERROR; } - rec->input_name = (gchar *)g_memdup(read_buffer + K12_SRCDESC_HWPART + hwpart_len, name_len); - rec->stack_file = (gchar *)g_memdup(read_buffer + K12_SRCDESC_HWPART + hwpart_len + name_len, stack_len); + rec->input_name = (gchar *)g_memdup2(read_buffer + K12_SRCDESC_HWPART + hwpart_len, name_len); + rec->stack_file = (gchar *)g_memdup2(read_buffer + K12_SRCDESC_HWPART + hwpart_len + name_len, stack_len); ascii_strdown_inplace (rec->stack_file); diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c index 0ab01055c8..48ce5f707b 100644 --- a/wiretap/pcapng.c +++ b/wiretap/pcapng.c @@ -23,6 +23,7 @@ #include <wsutil/ws_printf.h> #include <wsutil/strtoi.h> +#include <wsutil/glib-compat.h> #include "wtap-int.h" #include "file_wrappers.h" @@ -1662,7 +1663,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, wblock->rec->packet_verdict = g_ptr_array_new_with_free_func((GDestroyNotify) g_bytes_unref); } - option_content_copy = g_memdup(option_content, oh->option_length); + option_content_copy = g_memdup2(option_content, oh->option_length); /* For Linux XDP and TC we might need to byte swap */ if (section_info->byte_swapped && diff --git a/wiretap/wtap_opttypes.c b/wiretap/wtap_opttypes.c index 1e3e3ec798..b887b4bc14 100644 --- a/wiretap/wtap_opttypes.c +++ b/wiretap/wtap_opttypes.c @@ -16,6 +16,8 @@ #include "wtap-int.h" #include "pcapng_module.h" +#include <wsutil/glib-compat.h> + #if 0 #define wtap_debug(...) g_warning(__VA_ARGS__) #else @@ -773,7 +775,7 @@ static if_filter_opt_t if_filter_dup(if_filter_opt_t* filter_src) filter_dest.data.bpf_prog.bpf_prog_len = filter_src->data.bpf_prog.bpf_prog_len; filter_dest.data.bpf_prog.bpf_prog = - (wtap_bpf_insn_t *)g_memdup(filter_src->data.bpf_prog.bpf_prog, + (wtap_bpf_insn_t *)g_memdup2(filter_src->data.bpf_prog.bpf_prog, filter_src->data.bpf_prog.bpf_prog_len * sizeof (wtap_bpf_insn_t)); break; @@ -1019,7 +1021,7 @@ static void dsb_copy_mand(wtap_block_t dest_block, wtap_block_t src_block) dst->secrets_type = src->secrets_type; dst->secrets_len = src->secrets_len; g_free(dst->secrets_data); - dst->secrets_data = (guint8 *)g_memdup(src->secrets_data, src->secrets_len); + dst->secrets_data = (guint8 *)g_memdup2(src->secrets_data, src->secrets_len); } void wtap_opttypes_initialize(void) |