diff options
author | Guy Harris <gharris@sonic.net> | 2021-01-19 19:02:01 -0800 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-01-19 19:02:01 -0800 |
commit | 64f1d09ef332511e3caf17fb5943c404c55df5fd (patch) | |
tree | 73cce04c29ca4a41cb0d2ca0b6aae4a05fccfa68 | |
parent | 6db087ae4b67b9c1f6e193ce3b7606345988d51d (diff) |
Make various max packet sizes unsigned, and clean up from that.
Make some packet size variables unsigned.
Leave some others signed, because they're read with sscanf(), and
sscanf() handles string-to-unsigned conversions in the same crazy way
strtouX() routines do, wherein a leading sign is *not* an error.
Instead, cast them to unsigned after we make sure they're not negative.
-rw-r--r-- | wiretap/cosine.c | 4 | ||||
-rw-r--r-- | wiretap/eyesdn.c | 2 | ||||
-rw-r--r-- | wiretap/hcidump.c | 2 | ||||
-rw-r--r-- | wiretap/iseries.c | 2 | ||||
-rw-r--r-- | wiretap/netscreen.c | 4 | ||||
-rw-r--r-- | wiretap/toshiba.c | 4 | ||||
-rw-r--r-- | wiretap/wtap.h | 8 |
7 files changed, 13 insertions, 13 deletions
diff --git a/wiretap/cosine.c b/wiretap/cosine.c index 3248656f1a..f665816c14 100644 --- a/wiretap/cosine.c +++ b/wiretap/cosine.c @@ -367,14 +367,14 @@ parse_cosine_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, *err_info = g_strdup("cosine: packet header has a negative packet length"); return FALSE; } - if (pkt_len > WTAP_MAX_PACKET_SIZE_STANDARD) { + if ((guint)pkt_len > WTAP_MAX_PACKET_SIZE_STANDARD) { /* * Probably a corrupt capture file; don't blow up trying * to allocate space for an immensely-large packet. */ *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("cosine: File has %u-byte packet, bigger than maximum of %u", - pkt_len, WTAP_MAX_PACKET_SIZE_STANDARD); + (guint)pkt_len, WTAP_MAX_PACKET_SIZE_STANDARD); return FALSE; } diff --git a/wiretap/eyesdn.c b/wiretap/eyesdn.c index b5329d3f09..63bb0ce309 100644 --- a/wiretap/eyesdn.c +++ b/wiretap/eyesdn.c @@ -175,7 +175,7 @@ read_eyesdn_rec(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, guint8 hdr[EYESDN_HDR_LENGTH]; time_t secs; int usecs; - int pkt_len; + guint pkt_len; guint8 channel, direction; guint8 *pd; diff --git a/wiretap/hcidump.c b/wiretap/hcidump.c index 9e917a1d39..92cc05064a 100644 --- a/wiretap/hcidump.c +++ b/wiretap/hcidump.c @@ -25,7 +25,7 @@ static gboolean hcidump_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) { struct dump_hdr dh; - int packet_size; + guint packet_size; if (!wtap_read_bytes_or_eof(fh, &dh, DUMP_HDR_SIZE, err, err_info)) return FALSE; diff --git a/wiretap/iseries.c b/wiretap/iseries.c index 6f55fe110f..38f35b9b90 100644 --- a/wiretap/iseries.c +++ b/wiretap/iseries.c @@ -731,7 +731,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, wtap_rec *rec, * Check the length first, just in case it's *so* big that, after * adding the Ethernet header length, it overflows. */ - if (pkt_len > WTAP_MAX_PACKET_SIZE_STANDARD - 14) + if ((guint)pkt_len > WTAP_MAX_PACKET_SIZE_STANDARD - 14) { /* * Probably a corrupt capture file; don't blow up trying diff --git a/wiretap/netscreen.c b/wiretap/netscreen.c index 9ad825f52f..08de995e0c 100644 --- a/wiretap/netscreen.c +++ b/wiretap/netscreen.c @@ -277,14 +277,14 @@ parse_netscreen_packet(FILE_T fh, wtap_rec *rec, Buffer* buf, *err_info = g_strdup("netscreen: packet header has a negative packet length"); return FALSE; } - if (pkt_len > WTAP_MAX_PACKET_SIZE_STANDARD) { + if ((guint)pkt_len > WTAP_MAX_PACKET_SIZE_STANDARD) { /* * Probably a corrupt capture file; don't blow up trying * to allocate space for an immensely-large packet. */ *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("netscreen: File has %u-byte packet, bigger than maximum of %u", - pkt_len, WTAP_MAX_PACKET_SIZE_STANDARD); + (guint)pkt_len, WTAP_MAX_PACKET_SIZE_STANDARD); return FALSE; } diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c index 7f582f0219..362cbcb494 100644 --- a/wiretap/toshiba.c +++ b/wiretap/toshiba.c @@ -298,14 +298,14 @@ parse_toshiba_packet(FILE_T fh, wtap_rec *rec, Buffer *buf, *err_info = g_strdup("toshiba: packet header has a negative packet length"); return FALSE; } - if (pkt_len > WTAP_MAX_PACKET_SIZE_STANDARD) { + if ((guint)pkt_len > WTAP_MAX_PACKET_SIZE_STANDARD) { /* * Probably a corrupt capture file; don't blow up trying * to allocate space for an immensely-large packet. */ *err = WTAP_ERR_BAD_FILE; *err_info = g_strdup_printf("toshiba: File has %u-byte packet, bigger than maximum of %u", - pkt_len, WTAP_MAX_PACKET_SIZE_STANDARD); + (guint)pkt_len, WTAP_MAX_PACKET_SIZE_STANDARD); return FALSE; } diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 9eef03dd40..ba789ef98e 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -426,10 +426,10 @@ extern "C" { * greater than 262144 if we don't have to, as software reading those * files might allocate a buffer much larger than necessary, wasting memory. */ -#define WTAP_MAX_PACKET_SIZE_STANDARD 262144 -#define WTAP_MAX_PACKET_SIZE_USBPCAP (128*1024*1024) -#define WTAP_MAX_PACKET_SIZE_EBHSCR (8*1024*1024) -#define WTAP_MAX_PACKET_SIZE_DBUS (128*1024*1024) +#define WTAP_MAX_PACKET_SIZE_STANDARD 262144U +#define WTAP_MAX_PACKET_SIZE_USBPCAP (128U*1024U*1024U) +#define WTAP_MAX_PACKET_SIZE_EBHSCR (8U*1024U*1024U) +#define WTAP_MAX_PACKET_SIZE_DBUS (128U*1024U*1024U) /* * "Pseudo-headers" are used to supply to the clients of wiretap |