aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2017-03-13 17:02:23 +0100
committerMichael Mann <mmann78@netscape.net>2017-03-13 21:46:38 +0000
commit98558fd81cad9d578ea5085fe8465334e4b266fd (patch)
tree62919d27d2bbd60edfc9406a557f284002d62e15
parentf1d0533ee1f051aabbc1ba8e3e6a9b51dbb2c228 (diff)
Fix buffer overrun in try_bytesprefix_to_str
bytes_string list contains a list of prefixes to match, not the other way round (matching prefixes in the list). Bug: 13479 Change-Id: Ie625dc5db30bd55158d688a0101f35d0bf6906af Fixes: v2.3.0rc0-2644-g540b555729 ("Introduce "bytes_string" type, similar to "value_string"") Reviewed-on: https://code.wireshark.org/review/20532 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--epan/value_string.c13
-rw-r--r--epan/value_string.h4
2 files changed, 9 insertions, 8 deletions
diff --git a/epan/value_string.c b/epan/value_string.c
index 858a6d25fd..1c665bb5bf 100644
--- a/epan/value_string.c
+++ b/epan/value_string.c
@@ -683,15 +683,15 @@ try_bytesval_to_str(const guint8 *val, const size_t val_len, const bytes_string
}
/* Like val_to_str, but tries to find a prefix (instead of an exact) match
- against any element of the bytes_string array bs. */
+ of any prefix from the bytes_string array bs against the haystack. */
const gchar *
-bytesprefix_to_str(const guint8 *prefix, const size_t prefix_len, const bytes_string *bs, const char *fmt)
+bytesprefix_to_str(const guint8 *haystack, const size_t haystack_len, const bytes_string *bs, const char *fmt)
{
const gchar *ret;
DISSECTOR_ASSERT(fmt != NULL);
- ret = try_bytesprefix_to_str(prefix, prefix_len, bs);
+ ret = try_bytesprefix_to_str(haystack, haystack_len, bs);
if (ret != NULL)
return ret;
@@ -700,15 +700,16 @@ bytesprefix_to_str(const guint8 *prefix, const size_t prefix_len, const bytes_st
}
/* Like try_val_to_str, but tries to find a prefix (instead of an exact) match
- against any element of the bytes_string array bs. */
+ of any prefix from the bytes_string array bs against the haystack. */
const gchar *
-try_bytesprefix_to_str(const guint8 *prefix, const size_t prefix_len, const bytes_string *bs)
+try_bytesprefix_to_str(const guint8 *haystack, const size_t haystack_len, const bytes_string *bs)
{
guint i = 0;
if (bs) {
while (bs[i].strptr) {
- if (prefix_len >= bs[i].value_length && !memcmp(bs[i].value, prefix, prefix_len)) {
+ if (haystack_len >= bs[i].value_length &&
+ !memcmp(bs[i].value, haystack, bs[i].value_length)) {
return bs[i].strptr;
}
i++;
diff --git a/epan/value_string.h b/epan/value_string.h
index 92d24deb97..07a2eb92e2 100644
--- a/epan/value_string.h
+++ b/epan/value_string.h
@@ -293,12 +293,12 @@ try_bytesval_to_str(const guint8 *val, const size_t val_len, const bytes_string
WS_DLL_PUBLIC
const gchar *
-bytesprefix_to_str(const guint8 *prefix, const size_t prefix_len, const bytes_string *bs, const char *fmt)
+bytesprefix_to_str(const guint8 *haystack, const size_t haystack_len, const bytes_string *bs, const char *fmt)
G_GNUC_PRINTF(4, 0);
WS_DLL_PUBLIC
const gchar *
-try_bytesprefix_to_str(const guint8 *prefix, const size_t prefix_len, const bytes_string *bs);
+try_bytesprefix_to_str(const guint8 *haystack, const size_t haystack_len, const bytes_string *bs);
/* MISC (generally do not use) */