[llvm-commits] [ASan] Define an internal implementation of strchr to make stack OOB tests pass (issue 5668047)
Marshall Clow
mclow.lists at gmail.com
Tue Feb 14 10:12:37 PST 2012
On Feb 14, 2012, at 9:47 AM, timurrrr at google.com wrote:
> Reviewers: kcc1,
>
> Message:
> Hi Kostya,
>
> Can you please review this small patch?
>
> Thanks!
>
> Description:
> Define an internal implementation of strchr to make stack OOB tests pass
>
> Please review this at http://codereview.appspot.com/5668047/
>
> Affected files:
> M lib/asan/asan_interceptors.cc
> M lib/asan/asan_rtl.cc
>
> +char* internal_strchr(const char *s, int c) {
> + for (size_t i = 0; ; ++i) {
> + if (s[i] == (char)c)
> + return (char*)&s[i];
> + if (s[i] == 0)
> + return NULL;
> + }
> +}
Isn't strchr defined to return a const char *?
And why all the mucking about with indexes?
How about:
const char* internal_strchr(const char *s, int c) {
for ( ; *s; ++s )
if ( *s == c )
return s;
return NULL;
}
instead?
-- Marshall
Marshall Clow Idio Software <mailto:mclow.lists at gmail.com>
A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
-- Yu Suzuki
More information about the llvm-commits
mailing list