Skip to content

Commit

Permalink
argdist: Generated streq-helper to ignore null terminator
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
goldshtn committed Jan 17, 2017
1 parent 50486ff commit fd44cd2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/argdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def _generate_streq_function(self, string):
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;
}
Expand Down

0 comments on commit fd44cd2

Please sign in to comment.