diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-07-06 15:34:38 +0200 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2014-07-06 23:00:40 +0000 |
commit | f2b4daf4005d60eef7e34e2e6ebf4fe487d3c255 (patch) | |
tree | 1fac15d7bcbc381c5e0a3a6602e7edd20e574e39 /echld | |
parent | ec6a22dc3ba8e2d438b34d892d6a40e1be2a28f2 (diff) |
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>
Diffstat (limited to 'echld')
-rw-r--r-- | echld/echld-int.h | 2 | ||||
-rw-r--r-- | echld/echld.h | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/echld/echld-int.h b/echld/echld-int.h index acf5557a97..8bbd1f9a14 100644 --- a/echld/echld-int.h +++ b/echld/echld-int.h @@ -167,7 +167,7 @@ extern echld_bool_t paramset_apply_set (param_t* paramsets, char* name, char* va extern echld_bool_t paramset_apply_em(param_t* paramset, enc_msg_t* em, char** err); #define PARAM_LIST_FMT "%s(%s): %s\n" /* name, rw|ro|wo, desc */ -char* paramset_get_params_list(param_t* paramsets,const char* fmt); +char* paramset_get_params_list(param_t* paramsets, const char* fmt) G_GNUC_PRINTF(2, 0); #define PARAM_STR(Name, Default) static char* param_ ## Name = Default; \ static char* param_get_ ## Name (char** err _U_ ) { return (param_ ## Name) ? g_strdup(param_ ## Name) : (*err = g_strdup( #Name " not set"), NULL); } \ diff --git a/echld/echld.h b/echld/echld.h index ff341705bc..5c224a088b 100644 --- a/echld/echld.h +++ b/echld/echld.h @@ -188,7 +188,9 @@ WS_DLL_PUBLIC enc_msg_t* echld_new_child_params_merge(enc_msg_t*, enc_msg_t*); #define ECHLD_NC_PARAMS_FMT " %s='%s',\n" /* param='value' */ /* truncate takes off last N chars from the last item's fmt or prefix on empty */ -WS_DLL_PUBLIC char* echld_new_child_params_str(enc_msg_t* em, const char* prefix, const char* postfix, int truncate, const char* fmt); +WS_DLL_PUBLIC char* echld_new_child_params_str(enc_msg_t* em, + const char* prefix, const char* postfix, int truncate, const char* fmt) + G_GNUC_FORMAT(5, 0); /* create a new worker process */ |