From c1deca140141a05d6d6a82b854eafa0f11c21e63 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 4 May 2018 23:40:40 +0200 Subject: smb: fix memleak in export objects "aux_smb_fid_type_string" is used as "%s" argument for g_strdup_printf, there is no need to clone it. I checked all calls and "fid_type" should always be valid, but in case of a bug, let's not return a NULL pointer but "?". Found by Clang Static Analyzer. Change-Id: I09896638eb5512f22b3d1a227462499e12cedcde Reviewed-on: https://code.wireshark.org/review/27349 Petri-Dish: Peter Wu Tested-by: Petri Dish Buildbot Reviewed-by: ronnie sahlberg --- epan/dissectors/packet-smb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'epan') diff --git a/epan/dissectors/packet-smb.c b/epan/dissectors/packet-smb.c index 53d77db222..2c509104c7 100644 --- a/epan/dissectors/packet-smb.c +++ b/epan/dissectors/packet-smb.c @@ -1231,12 +1231,12 @@ smb_eo_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const gboolean is_supported_filetype; gfloat percent; - gchar *aux_smb_fid_type_string; + const gchar *aux_smb_fid_type_string; if (eo_info->smbversion==1) { /* Is this an eo_smb supported file_type? (right now we only support FILE) */ is_supported_filetype = (eo_info->fid_type == SMB_FID_TYPE_FILE); - aux_smb_fid_type_string=g_strdup(try_val_to_str(eo_info->fid_type, smb_fid_types)); + aux_smb_fid_type_string = val_to_str_const(eo_info->fid_type, smb_fid_types, "?"); /* What kind of data this packet contains? */ switch(eo_info->cmd) { @@ -1255,7 +1255,7 @@ smb_eo_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const } else { /* Is this an eo_smb supported file_type? (right now we only support FILE) */ is_supported_filetype = (eo_info->fid_type == SMB2_FID_TYPE_FILE ); - aux_smb_fid_type_string=g_strdup(try_val_to_str(eo_info->fid_type, smb2_fid_types)); + aux_smb_fid_type_string = val_to_str_const(eo_info->fid_type, smb2_fid_types, "?"); /* What kind of data this packet contains? */ switch(eo_info->cmd) { -- cgit v1.2.3