From 3063a4b069b2fabd5ff53c702581d04ed41f573f Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Fri, 14 Jan 2022 12:43:19 -0500 Subject: [PATCH] let's use name_len instead of walking off of the end of arrays --- src/lib/util/dict_util.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/util/dict_util.c b/src/lib/util/dict_util.c index df10c65d69..85913c9d21 100644 --- a/src/lib/util/dict_util.c +++ b/src/lib/util/dict_util.c @@ -229,9 +229,16 @@ static int8_t dict_enum_name_cmp(void const *one, void const *two) { fr_dict_enum_value_t const *a = one; fr_dict_enum_value_t const *b = two; + size_t len; int ret; - ret = strcasecmp(a->name, b->name); + if (a->name_len >= b->name_len) { + len = a->name_len; + } else { + len = b->name_len; + } + + ret = strncasecmp(a->name, b->name, len); return CMP(ret, 0); } -- 2.47.2