summaryrefslogtreecommitdiffstats
path: root/epan/strutil.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-26 17:44:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-26 17:44:25 +0000
commitf59ea5f7690c9a01ef6f7f6508084a66c40b1dae (patch)
tree482ee255d71f113be6c62e9ff3543fd6ebb9f12a /epan/strutil.c
parentReleasing progress-linux version 4.2.2-1.1~progress7.99u1. (diff)
downloadwireshark-f59ea5f7690c9a01ef6f7f6508084a66c40b1dae.tar.xz
wireshark-f59ea5f7690c9a01ef6f7f6508084a66c40b1dae.zip
Merging upstream version 4.2.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'epan/strutil.c')
-rw-r--r--epan/strutil.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/epan/strutil.c b/epan/strutil.c
index c3546a39..88260ad8 100644
--- a/epan/strutil.c
+++ b/epan/strutil.c
@@ -131,6 +131,10 @@ is_byte_sep(guint8 c)
/* Turn a string of hex digits with optional separators (defined by
* is_byte_sep() into a byte array.
+ *
+ * XXX - This function is perhaps too generous in what it accepts.
+ * It allows the separator to change from one character to another,
+ * or to and from no separator if force_separators is false.
*/
gboolean
hex_str_to_bytes(const char *hex_str, GByteArray *bytes, gboolean force_separators)
@@ -152,9 +156,19 @@ hex_str_to_bytes(const char *hex_str, GByteArray *bytes, gboolean force_separato
r = p+2;
s = p+3;
- if (*q && *r && *s
+ if (*q && *r
&& g_ascii_isxdigit(*p) && g_ascii_isxdigit(*q) &&
- g_ascii_isxdigit(*r) && g_ascii_isxdigit(*s)) {
+ g_ascii_isxdigit(*r)) {
+
+ /*
+ * Three hex bytes in a row, followed by a non hex byte
+ * (possibly the end of the string). We don't accept an
+ * odd number of hex digits except for single digits
+ * by themselves or after a separator.
+ */
+ if (!g_ascii_isxdigit(*s)) {
+ return FALSE;
+ }
four_digits_first_half[0] = *p;
four_digits_first_half[1] = *q;
four_digits_first_half[2] = '\0';
@@ -174,7 +188,7 @@ hex_str_to_bytes(const char *hex_str, GByteArray *bytes, gboolean force_separato
if (*punct) {
/*
* Make sure the character after
- * the forth hex digit is a byte
+ * the fourth hex digit is a byte
* separator, i.e. that we don't have
* more than four hex digits, or a
* bogus character.