From f2b4daf4005d60eef7e34e2e6ebf4fe487d3c255 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Sun, 6 Jul 2014 15:34:38 +0200 Subject: Add printf-format annotations, fix garbage The WRETH dissector showed up some garbage in the column display. Upon further inspection, it turns out that the format string had a trailing percent sign which caused (unsigned)-1 to be returned by g_printf_string_upper_bound (in emem_strdup_vprintf). Then ep_alloc is called with (unsigned)-1 + 1 = 0 memory, no wonder that garbage shows up. ASAN could not even catch this error because EP is in charge of this. So, start adding G_GNUC_PRINTF annotations in each header that uses the "fmt" or "format" paramters (grepped + awk). This revealed some other errors. The NCP2222 dissector was missing a format string (not a security vuln though). Many dissectors used val_to_str with a constant (but empty) string, these have been replaced by val_to_str_const. ASN.1 dissectors were regenerated for this. Minor: the mate plugin used "%X" instead of "%p" for a pointer type. The ncp2222 dissector and wimax plugin gained modelines. Change-Id: I7f3f6a3136116f9b251719830a39a7b21646f622 Reviewed-on: https://code.wireshark.org/review/2881 Reviewed-by: Evan Huus --- epan/dissectors/packet-x509if.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'epan/dissectors/packet-x509if.c') diff --git a/epan/dissectors/packet-x509if.c b/epan/dissectors/packet-x509if.c index fe6cae6de4..487794506c 100644 --- a/epan/dissectors/packet-x509if.c +++ b/epan/dissectors/packet-x509if.c @@ -744,7 +744,7 @@ dissect_x509if_T_type_02(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offse proto_item_append_text(tree, " (%s)", name); } - if((fmt = val_to_str(hf_index, fmt_vals, "")) && *fmt) { + if((fmt = val_to_str_const(hf_index, fmt_vals, "")) && *fmt) { /* we have a format */ last_ava = (char *)wmem_alloc(wmem_packet_scope(), MAX_AVA_STR_LEN); *last_ava = '\0'; register_frame_end_routine (actx->pinfo, x509if_frame_end); @@ -796,7 +796,7 @@ dissect_x509if_T_atadv_value(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int o proto_item_append_text(tree, "%s)", value); } - if((fmt = val_to_str(ava_hf_index, fmt_vals, "")) && *fmt) { + if((fmt = val_to_str_const(ava_hf_index, fmt_vals, "")) && *fmt) { /* we have a format */ if (!last_ava) { @@ -985,7 +985,7 @@ dissect_x509if_RDNSequence(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int off proto_item_append_text(top_of_dn, " (%s)", last_dn); /* see if we should append this to the col info */ - if((fmt = val_to_str(hf_index, fmt_vals, "")) && *fmt) { + if((fmt = val_to_str_const(hf_index, fmt_vals, "")) && *fmt) { /* we have a format */ col_append_fstr(actx->pinfo->cinfo, COL_INFO, " %s%s", fmt, last_dn); } -- cgit v1.2.3