packet-gsm_sms: Return early in hashing funtion when NULL passed in.
Avoid crashes when NULL passed into hashing functions. Change-Id: I941eec49ff8f906715ae257b61334a9533af3265 Reviewed-on: https://code.wireshark.org/review/37863 Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com> Petri-Dish: Richard Sharpe <realrichardsharpe@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
babbe57a1a
commit
1d8680d07f
|
@ -379,6 +379,9 @@ sm_fragment_hash(gconstpointer k)
|
|||
const sm_fragment_key* key = (const sm_fragment_key*) k;
|
||||
guint hash_val;
|
||||
|
||||
if (!key || !key->addr_info)
|
||||
return 0;
|
||||
|
||||
hash_val = (wmem_str_hash(key->addr_info) ^ key->id) + key->p2p_dir;
|
||||
|
||||
return hash_val;
|
||||
|
@ -390,6 +393,9 @@ sm_fragment_equal(gconstpointer k1, gconstpointer k2)
|
|||
const sm_fragment_key* key1 = (const sm_fragment_key*) k1;
|
||||
const sm_fragment_key* key2 = (const sm_fragment_key*) k2;
|
||||
|
||||
if (!key1 || !key2)
|
||||
return FALSE;
|
||||
|
||||
return (key1->id == key2->id) &&
|
||||
(key1->p2p_dir == key2->p2p_dir) &&
|
||||
!g_strcmp0(key1->addr_info, key2->addr_info) &&
|
||||
|
@ -402,8 +408,12 @@ sm_fragment_temporary_key(const packet_info *pinfo,
|
|||
const guint32 id, const void *data)
|
||||
{
|
||||
const gchar* addr = (const char*)data;
|
||||
sm_fragment_key *key = g_slice_new(sm_fragment_key);
|
||||
sm_fragment_key *key;
|
||||
|
||||
if (addr == NULL || pinfo->src.data == NULL || pinfo->dst.data == NULL)
|
||||
return NULL;
|
||||
|
||||
key = g_slice_new(sm_fragment_key);
|
||||
key->addr_info = addr;
|
||||
key->p2p_dir = pinfo->p2p_dir;
|
||||
copy_address_shallow(&key->src, &pinfo->src);
|
||||
|
@ -420,6 +430,9 @@ sm_fragment_persistent_key(const packet_info *pinfo,
|
|||
const gchar* addr = (const char*)data;
|
||||
sm_fragment_key *key = g_slice_new(sm_fragment_key);
|
||||
|
||||
if (addr == NULL || pinfo->src.data == NULL || pinfo->dst.data == NULL)
|
||||
return NULL;
|
||||
|
||||
key->addr_info = wmem_strdup(NULL, addr);
|
||||
key->p2p_dir = pinfo->p2p_dir;
|
||||
copy_address(&key->src, &pinfo->src);
|
||||
|
|
Loading…
Reference in New Issue