This is an archive of the discontinued LLVM Phabricator instance.

[asan] Get rid of UB in unit tests for strstr, strcasestr, strspn, strcspn and strpbrk interceptors.
ClosedPublic

Authored by m.ostapenko on Oct 20 2015, 7:01 AM.

Details

Summary

Following Eugeniy's suggestion in http://reviews.llvm.org/D10336, we can remove UB from tests for strstr, strcasestr, strspn, strcspn and strpbrk interceptors by extending corresponding string an poison it's tail manually.

Tested on x86_64-linux-gnu.
How does it look?

Diff Detail

Repository
rL LLVM

Event Timeline

m.ostapenko retitled this revision from to [asan] Get rid of UB in unit tests for strstr, strcasestr, strspn, strcspn and strpbrk interceptors..
m.ostapenko updated this object.
m.ostapenko added reviewers: eugenis, samsonov, ygribov.
m.ostapenko set the repository for this revision to rL LLVM.
m.ostapenko added a subscriber: llvm-commits.
eugenis added inline comments.Oct 20 2015, 11:51 AM
test/asan/TestCases/strcasestr-1.c
21 ↗(On Diff #37877)

This check could be made more strict now, right?
It should be always "s1" and always "overflows".

Addressing Eugeniy's nit. Make checks in tests more strict.

test/asan/TestCases/strcasestr-1.c
21 ↗(On Diff #37991)

Indeed, thanks. I'll update corresponding tests to use more strict checks.

eugenis accepted this revision.Oct 21 2015, 11:52 AM
eugenis edited edge metadata.

It also looks like "s3" is now unused in all tests.
LGTM when that's fixed.

This revision is now accepted and ready to land.Oct 21 2015, 11:52 AM
m.ostapenko edited edge metadata.

Thanks, attaching the patch to be committed.

This revision was automatically updated to reflect the committed changes.