From fd44cd244afa088303ee4b5a878980dda0f836ce Mon Sep 17 00:00:00 2001 From: Sasha Goldshtein Date: Mon, 16 Jan 2017 18:38:30 +0000 Subject: [PATCH] argdist: Generated streq-helper to ignore null terminator Oftentimes we want to use the STRCMP helper to compare strings that are not null-terminated, e.g. in USDT probes this often happens. Ignore the null terminator (i.e. loop until the last character excluding the null terminator). --- tools/argdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/argdist.py b/tools/argdist.py index 3bcf43a..f6bb8bf 100755 --- a/tools/argdist.py +++ b/tools/argdist.py @@ -258,7 +258,7 @@ static inline bool %s(char const *ignored, char const *str) { char needle[] = %s; char haystack[sizeof(needle)]; bpf_probe_read(&haystack, sizeof(haystack), (void *)str); - for (int i = 0; i < sizeof(needle); ++i) { + for (int i = 0; i < sizeof(needle)-1; ++i) { if (needle[i] != haystack[i]) { return false; } -- 2.7.4