From 9fba5f0764678cfed4b7ff2a41fdcb0babcdbf55 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 30 Apr 2015 15:21:00 -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.) Change-Id: I0d27565c382a04ceda9eec65f45a430ceb74cf53 Reviewed-on: https://code.wireshark.org/review/8255 Reviewed-by: Guy Harris --- epan/dissectors/packet-reload-framing.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'epan/dissectors/packet-reload-framing.c') diff --git a/epan/dissectors/packet-reload-framing.c b/epan/dissectors/packet-reload-framing.c index 9ec997dc7a..1eeddd9bc7 100644 --- a/epan/dissectors/packet-reload-framing.c +++ b/epan/dissectors/packet-reload-framing.c @@ -374,7 +374,7 @@ dissect_reload_framing_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr received = tvb_get_ntohl(tvb, offset); while ((received<=32) break; - if (received &(0x1<<(31-indx))) { + if (received &(1U<<(31-indx))) { if (indx==0) { received_tree = proto_item_add_subtree(ti_received, ett_reload_framing_received); ti_parsed_received = proto_tree_add_item(received_tree, hf_reload_framing_parsed_received, tvb, offset, 4, ENC_NA); @@ -382,7 +382,7 @@ dissect_reload_framing_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr last_received = indx; } else { - if (received &(0x1<<(31-indx+1))) { + if (received &(1U<<(31-indx+1))) { indx++; /* range: skip */ continue; @@ -404,9 +404,9 @@ dissect_reload_framing_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr } } else if (indx>0) { - if ((received &(0x1<<(31-indx+1))) && (received &(0x1<<(31-indx+2)))) { + if ((received &(1U<<(31-indx+1))) && (received &(1U<<(31-indx+2)))) { /* end of a series */ - if ((received &(0x1<<(31-indx+3)))) { + if ((received &(1U<<(31-indx+3)))) { proto_item_append_text(ti_parsed_received,"-%u",(sequence-32+indx-1)); } else { @@ -422,9 +422,9 @@ dissect_reload_framing_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr indx++; } if (last_received>=0) { - if ((received &(0x1<<(31-indx+1))) && (received &(0x1<<(31-indx+2)))) { + if ((received &(1U<<(31-indx+1))) && (received &(1U<<(31-indx+2)))) { /* end of a series */ - if ((received &(0x1<<(31-indx+3)))) { + if ((received &(1U<<(31-indx+3)))) { proto_item_append_text(ti_parsed_received,"-%u",(sequence-32+indx-1)); } else { -- cgit v1.2.1