[PATCH] D30384: [asan] Add an interceptor for strtok
Yury Gribov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 27 01:45:29 PST 2017
ygribov added a comment.
I suggest to regenerate patch with `-U99999`, to get more context.
================
Comment at: asan_interceptors.cc:549
+ ASAN_READ_RANGE(ctx, delimiters, del_size);
+ ASAN_READ_RANGE(ctx, str, str_size);
+ }
----------------
Please use `ASAN_READ_STRING` instead, similar to other string interceptors. `str_size` should be checked only if `strict_strings` is enabled, otherwise you can only check range up to first delimiter (inclusively).
================
Comment at: tests/asan_str_test.cc:118
+ // Normal call.
+ strtok(s, s);
+ // Cause out-of-bounds read by missing NULL terminator.
----------------
Better avoid aliasing, `strtok` arguments are restricted (more below).
================
Comment at: tests/asan_str_test.cc:121
+ EXPECT_DEATH(Ident(strtok(s, delim)), RightOOBReadMessage(0));
+ EXPECT_DEATH(Ident(strtok(delim, s)), RightOOBReadMessage(0));
+ s[size - 1] = 'a';
----------------
`delim` is somewhat misleading name cause it's also used in other context here.
================
Comment at: tests/asan_str_test.cc:123
+ s[size - 1] = 'a';
+ EXPECT_DEATH(Ident(strtok(s, s)), RightOOBReadMessage(0));
+ // Argument points to not-allocated memory.
----------------
What does this add to previous tests?
https://reviews.llvm.org/D30384
More information about the llvm-commits
mailing list