diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-07-06 15:34:38 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-07-07 19:50:27 +0000 |
commit | 337aebe3a9b4f3cb97630b6760281d6e70bbf2d1 (patch) | |
tree | f88de21b5955274d80d777e743e0f336315a8293 /asn1 | |
parent | 62173703c35cd9fd1c5c741f96d23eab40a4dae6 (diff) | |
download | wireshark-337aebe3a9b4f3cb97630b6760281d6e70bbf2d1.tar.gz |
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 <eapache@gmail.com>
(cherry picked from commit f2b4daf4005d60eef7e34e2e6ebf4fe487d3c255)
Reviewed-on: https://code.wireshark.org/review/2923
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'asn1')
-rw-r--r-- | asn1/h450-ros/h450-ros.cnf | 8 | ||||
-rw-r--r-- | asn1/q932-ros/q932-ros.cnf | 8 | ||||
-rw-r--r-- | asn1/x509if/x509if.cnf | 6 |
3 files changed, 11 insertions, 11 deletions
diff --git a/asn1/h450-ros/h450-ros.cnf b/asn1/h450-ros/h450-ros.cnf index 480759c7dc..9915c20117 100644 --- a/asn1/h450-ros/h450-ros.cnf +++ b/asn1/h450-ros/h450-ros.cnf @@ -47,16 +47,16 @@ InvokeProblem VAL_PTR = &problem_val ReturnResultProblem VAL_PTR = &problem_val ReturnErrorProblem VAL_PTR = &problem_val #.FN_FTR GeneralProblem - g_strlcpy(problem_str, val_to_str(problem_val, VALS(h450_ros_GeneralProblem_vals), ""), 64); + g_strlcpy(problem_str, val_to_str_const(problem_val, VALS(h450_ros_GeneralProblem_vals), ""), 64); problem_str[64-1] = '\0'; #.FN_FTR InvokeProblem - g_strlcpy(problem_str, val_to_str(problem_val, VALS(h450_ros_InvokeProblem_vals), ""), 64); + g_strlcpy(problem_str, val_to_str_const(problem_val, VALS(h450_ros_InvokeProblem_vals), ""), 64); problem_str[64-1] = '\0'; #.FN_FTR ReturnResultProblem - g_strlcpy(problem_str, val_to_str(problem_val, VALS(h450_ros_ReturnResultProblem_vals), ""), 64); + g_strlcpy(problem_str, val_to_str_const(problem_val, VALS(h450_ros_ReturnResultProblem_vals), ""), 64); problem_str[64-1] = '\0'; #.FN_FTR ReturnErrorProblem - g_strlcpy(problem_str, val_to_str(problem_val, VALS(h450_ros_ReturnErrorProblem_vals), ""), 64); + g_strlcpy(problem_str, val_to_str_const(problem_val, VALS(h450_ros_ReturnErrorProblem_vals), ""), 64); problem_str[64-1] = '\0'; #.END diff --git a/asn1/q932-ros/q932-ros.cnf b/asn1/q932-ros/q932-ros.cnf index fc4e4eec1f..040ff64249 100644 --- a/asn1/q932-ros/q932-ros.cnf +++ b/asn1/q932-ros/q932-ros.cnf @@ -50,13 +50,13 @@ InvokeProblem VAL_PTR = &problem_val ReturnResultProblem VAL_PTR = &problem_val ReturnErrorProblem VAL_PTR = &problem_val #.FN_FTR GeneralProblem - g_strlcpy(problem_str, val_to_str(problem_val, VALS(q932_ros_GeneralProblem_vals), ""), 64); + g_strlcpy(problem_str, val_to_str_const(problem_val, VALS(q932_ros_GeneralProblem_vals), ""), 64); #.FN_FTR InvokeProblem - g_strlcpy(problem_str, val_to_str(problem_val, VALS(q932_ros_InvokeProblem_vals), ""), 64); + g_strlcpy(problem_str, val_to_str_const(problem_val, VALS(q932_ros_InvokeProblem_vals), ""), 64); #.FN_FTR ReturnResultProblem - g_strlcpy(problem_str, val_to_str(problem_val, VALS(q932_ros_ReturnResultProblem_vals), ""), 64); + g_strlcpy(problem_str, val_to_str_const(problem_val, VALS(q932_ros_ReturnResultProblem_vals), ""), 64); #.FN_FTR ReturnErrorProblem - g_strlcpy(problem_str, val_to_str(problem_val, VALS(q932_ros_ReturnErrorProblem_vals), ""), 64); + g_strlcpy(problem_str, val_to_str_const(problem_val, VALS(q932_ros_ReturnErrorProblem_vals), ""), 64); #.END #--- INVOKE --- diff --git a/asn1/x509if/x509if.cnf b/asn1/x509if/x509if.cnf index ab4b47a147..d54bdaf295 100644 --- a/asn1/x509if/x509if.cnf +++ b/asn1/x509if/x509if.cnf @@ -208,7 +208,7 @@ DistinguishedName B "2.16.840.1.101.2.2.1.188" "id-at-primaryMember" 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); @@ -251,7 +251,7 @@ DistinguishedName B "2.16.840.1.101.2.2.1.188" "id-at-primaryMember" 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) { @@ -384,7 +384,7 @@ DistinguishedName B "2.16.840.1.101.2.2.1.188" "id-at-primaryMember" 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); } |