From: Benjamin Berg Date: Fri, 14 Jun 2024 08:13:49 +0000 (+0200) Subject: trace: Use strncmp() to match function names X-Git-Tag: hostap_2_11~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49344db0954e463f54cfbd05b7898575b2c8c734;p=thirdparty%2Fhostap.git trace: Use strncmp() to match function names The functions specified by the user might be longer than the function in the backtrace, potentially overflowing the memcmp(). In practice, it should not be a relevant out-of-memory read. However, we can use strncmp() instead. Note that, as before, this is only a prefix match. If a function name is longer in the backtrace it will still match. Signed-off-by: Benjamin Berg --- diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c index d5870669a..b665c79a2 100644 --- a/src/utils/os_unix.c +++ b/src/utils/os_unix.c @@ -611,7 +611,7 @@ int testing_test_fail(const char *tag, bool is_alloc) len = next - pos; else len = os_strlen(pos); - if (os_memcmp(pos, func[i], len) != 0) { + if (os_strncmp(pos, func[i], len) != 0) { if (maybe && next) { pos = next + 1; continue;