From 5a3addd8eb3f7d2d8c8ceaf2789881ff9540bf31 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Thu, 21 Dec 2017 16:23:42 +0100 Subject: Fix possible signed overflow Shouldn't have led to problems so far, assuming sane overflow behavior and sizeof (int) == sizeof (guint32), but better safe than sorry. Change-Id: I1e154b311b9f0e3113bc9c7b4d8456ede16804ef Reviewed-on: https://code.wireshark.org/review/24930 Petri-Dish: Roland Knall Tested-by: Petri Dish Buildbot Reviewed-by: Martin Kaiser --- epan/dissectors/packet-epl-profile-parser.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'epan/dissectors/packet-epl-profile-parser.c') diff --git a/epan/dissectors/packet-epl-profile-parser.c b/epan/dissectors/packet-epl-profile-parser.c index e4699a7254..31a62f26e5 100644 --- a/epan/dissectors/packet-epl-profile-parser.c +++ b/epan/dissectors/packet-epl-profile-parser.c @@ -672,10 +672,18 @@ epl_wmem_iarray_insert(epl_wmem_iarray_t *iarr, guint32 where, range_admin_t *da g_array_append_vals(iarr->arr, data, 1); } +static int u32cmp(guint32 a, guint32 b) +{ + if (a < b) return -1; + if (a > b) return +1; + + return 0; +} + static int epl_wmem_iarray_cmp(const void *a, const void *b) { - return *(const guint32*)a - *(const guint32*)b; + return u32cmp(*(const guint32*)a, *(const guint32*)b); } /** Makes array suitable for searching */ @@ -716,7 +724,7 @@ find_in_range(const void *_a, const void *_b) if (a->low <= b->high && b->low <= a->high) /* overlap */ return 0; - return a->low - b->low; + return u32cmp(a->low, b->low); } static void* -- cgit v1.2.3