diff options
author | Guy Harris <guy@alum.mit.edu> | 2018-04-09 23:06:47 -0700 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-04-10 14:55:45 +0000 |
commit | c7970d9356a494d847101c2bd92e4ca97a7d3d58 (patch) | |
tree | e894b469ecc2c26563fbce3a9512af9bad66c594 /epan/dissectors/packet-iec104.c | |
parent | 2cb93e2121eea20c1e443558d7175f1cab8e1f70 (diff) |
Add, and use, "fetch signed value" for lengths < 40 bits.
Add 8-bit, 16-bit, 24-bit, and 32-bit "fetch signed value" routines, and
use them rather than casting the result of the 8/16/24/32-bit "fetch
unsigned value" routines to a signed type (which, BTW, isn't sufficient
for 24-bit values, so this appears to fix a bug
in epan/dissectors/packet-zbee-zcl.c).
Use numbers rather than sizeof()s in various tvb_get_ routines.
Change-Id: I0e48a57fac9f70fe42de815c3fa915f1592548bd
Reviewed-on: https://code.wireshark.org/review/26844
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-iec104.c')
-rw-r--r-- | epan/dissectors/packet-iec104.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/epan/dissectors/packet-iec104.c b/epan/dissectors/packet-iec104.c index 65c784e9cf..2248173bf1 100644 --- a/epan/dissectors/packet-iec104.c +++ b/epan/dissectors/packet-iec104.c @@ -1,7 +1,6 @@ /* packet-iec104.c * Routines for IEC-60870-5-104 (iec104) Protocol disassembly * - * * Copyright (c) 2008 by Joan Ramio <joan@ramio.cat> * Joan is a masculine catalan name. Search the Internet for Joan Pujol (alias Garbo). * @@ -884,7 +883,7 @@ static void get_NVA(tvbuff_t *tvb, guint8 *offset, proto_tree *iec104_header_tre gint16 value; float fvalue; - value = (gint16)tvb_get_letohs(tvb, *offset); + value = tvb_get_letohis(tvb, *offset); fvalue = (float)value / 32768; /* Normalized value F16[1..16]<-1..+1-2^-15> */ @@ -898,7 +897,7 @@ static void get_NVAspt(tvbuff_t *tvb, guint8 *offset, proto_tree *iec104_header_ gint16 value; float fvalue; - value = (gint16)tvb_get_letohs(tvb, *offset); + value = tvb_get_letohis(tvb, *offset); fvalue = (float)value / 32768; /* Normalized value F16[1..16]<-1..+1-2^-15> */ |