From b84972635117aa5cac7f8e6296d07ceb51bfe5e2 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 30 Apr 2015 20:03:39 -0700 Subject: Fix some cases where we're shifting a signed 1 left. Shift 1U instead, to make sure it's unsigned; the result of, for example, the result of shifting a signed value left is undefined if the value times 2^{shift count} doesn't fit in the *signed* type of the shifted value. That means, in particular, that the result of shifting 1 left by {number of bits in an int - 1} is undefined. (In *practice*, it'll probably be -2^32, with the bit you want set, but that's not guaranteed, and GCC 5.1 seems not to like it.) Make some other left-hand operands of <<, and some variables holding results from shifts of that sort, unsigned, while we're at it. Change-Id: Ie72a9d0d518f59b35948267d10c80735d162e8bb Reviewed-on: https://code.wireshark.org/review/8264 Reviewed-by: Guy Harris --- asn1/ess/packet-ess-template.c | 2 +- asn1/ranap/packet-ranap-template.c | 6 +++--- asn1/rrc/rrc.cnf | 16 +++++++-------- asn1/sv/packet-sv-template.c | 42 +++++++++++++++++++------------------- epan/dissectors/packet-ess.c | 2 +- epan/dissectors/packet-ranap.c | 6 +++--- epan/dissectors/packet-rrc.c | 16 +++++++-------- epan/dissectors/packet-sv.c | 42 +++++++++++++++++++------------------- 8 files changed, 66 insertions(+), 66 deletions(-) diff --git a/asn1/ess/packet-ess-template.c b/asn1/ess/packet-ess-template.c index 23a6854c8f..b9c20eb7c1 100644 --- a/asn1/ess/packet-ess-template.c +++ b/asn1/ess/packet-ess-template.c @@ -126,7 +126,7 @@ ess_dissect_attribute_flags (tvbuff_t *tvb, asn1_ctx_t *actx) if ((strcmp (u->oid, object_identifier_id) == 0) && ((u->lacv / 8) < tvb_captured_length (tvb)) && - (value[u->lacv / 8] & (1 << (7 - (u->lacv % 8))))) + (value[u->lacv / 8] & (1U << (7 - (u->lacv % 8))))) { proto_tree_add_string_format (tree, hf_ess_Category_attribute, tvb, u->lacv / 8, 1, u->name, diff --git a/asn1/ranap/packet-ranap-template.c b/asn1/ranap/packet-ranap-template.c index e20cc7b967..446fd8374c 100644 --- a/asn1/ranap/packet-ranap-template.c +++ b/asn1/ranap/packet-ranap-template.c @@ -104,9 +104,9 @@ static gboolean glbl_dissect_container = FALSE; * * Only these two needed currently */ -#define IMSG (1<<16) -#define SOUT (2<<16) -#define SPECIAL (4<<16) +#define IMSG (1U<<16) +#define SOUT (2U<<16) +#define SPECIAL (4U<<16) int pdu_type = 0; /* 0 means wildcard */ diff --git a/asn1/rrc/rrc.cnf b/asn1/rrc/rrc.cnf index 35059a634b..bf164f486e 100644 --- a/asn1/rrc/rrc.cnf +++ b/asn1/rrc/rrc.cnf @@ -737,8 +737,8 @@ HNBName TYPE=FT_STRING DISPLAY=STR_UNICODE /*Here we try to figure out which HS-DSCH channels are multiplexed*/ #.FN_BODY DL-TransportChannelType-r5 VAL_PTR = &type - gint *flowd_p; - gint *cur_val=NULL; + guint *flowd_p; + guint *cur_val=NULL; struct rrc_info *rrcinf; %(DEFAULT_BODY)s @@ -757,11 +757,11 @@ HNBName TYPE=FT_STRING DISPLAY=STR_UNICODE if( (cur_val=(gint *)g_tree_lookup(hsdsch_muxed_flows, GUINT_TO_POINTER((guint)rrcinf->hrnti[actx->pinfo->fd->subnum]))) == NULL ){ flowd_p = (guint*)g_malloc0(sizeof(gint)); - *flowd_p = (1<hrnti[actx->pinfo->fd->subnum]), flowd_p); }else{ - *cur_val = (1<hrnti[actx->pinfo->fd->subnum]))) == NULL ){ flowd_p = (guint*)g_malloc0(sizeof(gint)); - *flowd_p = (1<hrnti[actx->pinfo->fd->subnum]), flowd_p); }else{ - *cur_val = (1<oid, object_identifier_id) == 0) && ((u->lacv / 8) < tvb_captured_length (tvb)) && - (value[u->lacv / 8] & (1 << (7 - (u->lacv % 8))))) + (value[u->lacv / 8] & (1U << (7 - (u->lacv % 8))))) { proto_tree_add_string_format (tree, hf_ess_Category_attribute, tvb, u->lacv / 8, 1, u->name, diff --git a/epan/dissectors/packet-ranap.c b/epan/dissectors/packet-ranap.c index c96009a119..308c3f16dc 100644 --- a/epan/dissectors/packet-ranap.c +++ b/epan/dissectors/packet-ranap.c @@ -1507,9 +1507,9 @@ static gboolean glbl_dissect_container = FALSE; * * Only these two needed currently */ -#define IMSG (1<<16) -#define SOUT (2<<16) -#define SPECIAL (4<<16) +#define IMSG (1U<<16) +#define SOUT (2U<<16) +#define SPECIAL (4U<<16) int pdu_type = 0; /* 0 means wildcard */ diff --git a/epan/dissectors/packet-rrc.c b/epan/dissectors/packet-rrc.c index 1c130cc447..f2ed45aaeb 100644 --- a/epan/dissectors/packet-rrc.c +++ b/epan/dissectors/packet-rrc.c @@ -41428,8 +41428,8 @@ static int dissect_rrc_DL_TransportChannelType_r5(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { #line 739 "../../asn1/rrc/rrc.cnf" - gint *flowd_p; - gint *cur_val=NULL; + guint *flowd_p; + guint *cur_val=NULL; struct rrc_info *rrcinf; offset = dissect_per_choice(tvb, offset, actx, tree, hf_index, @@ -41451,11 +41451,11 @@ dissect_rrc_DL_TransportChannelType_r5(tvbuff_t *tvb _U_, int offset _U_, asn1_c if( (cur_val=(gint *)g_tree_lookup(hsdsch_muxed_flows, GUINT_TO_POINTER((guint)rrcinf->hrnti[actx->pinfo->fd->subnum]))) == NULL ){ flowd_p = (guint*)g_malloc0(sizeof(gint)); - *flowd_p = (1<hrnti[actx->pinfo->fd->subnum]), flowd_p); }else{ - *cur_val = (1<hrnti[actx->pinfo->fd->subnum]))) == NULL ){ flowd_p = (guint*)g_malloc0(sizeof(gint)); - *flowd_p = (1<hrnti[actx->pinfo->fd->subnum]), flowd_p); }else{ - *cur_val = (1<