forked from osmocom/wireshark
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>
This commit is contained in:
parent
f1d0533ee1
commit
98558fd81c
|
@ -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++;
|
||||
|
|
|
@ -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) */
|
||||
|
||||
|
|
Loading…
Reference in New Issue