This is an archive of the discontinued LLVM Phabricator instance.

Add interceptors for the strtoi(3)/strtou(3) from NetBSD
ClosedPublic

Authored by krytarowski on Nov 19 2018, 8:18 AM.

Details

Summary

strtoi/strtou converts string value to an intmax_t/uintmax_t integer.

Add a dedicated test.

Enable this API for NetBSD.

It's a reworked version of the original work by Yang Zheng.

Diff Detail

Repository
rL LLVM

Event Timeline

krytarowski created this revision.Nov 19 2018, 8:18 AM
vitalybuka added inline comments.Nov 19 2018, 11:19 AM
lib/sanitizer_common/sanitizer_common_interceptors.inc
7303 ↗(On Diff #174619)

There is INTERCEPTORS_STRTO_BASE in msan
Probably we should try to move them into common, and than add new interceptors.
If this is hard to move, then just add strtoi there

krytarowski added inline comments.Nov 19 2018, 11:55 AM
lib/sanitizer_common/sanitizer_common_interceptors.inc
7303 ↗(On Diff #174619)

Do you mean, to add strtoi for MSan only?

Yes, the interceptors shall be made generic.. however we are not able to do it in this iteration.

krytarowski added inline comments.Nov 19 2018, 12:00 PM
lib/sanitizer_common/sanitizer_common_interceptors.inc
7303 ↗(On Diff #174619)

BTW. I will drop you a line in a mail.

vitalybuka added inline comments.Nov 19 2018, 1:21 PM
lib/sanitizer_common/sanitizer_common_interceptors.inc
7326 ↗(On Diff #174619)

we need StrtolFixAndCheck and avoid reading entire string for strict_string_checks=0

vitalybuka added inline comments.Nov 19 2018, 1:24 PM
lib/sanitizer_common/sanitizer_common_interceptors.inc
7303 ↗(On Diff #174619)

not sure what is long term is better
maybe adding this just into msan and later converting to _common would be easier

vitalybuka requested changes to this revision.Nov 29 2018, 1:59 PM
This revision now requires changes to proceed.Nov 29 2018, 1:59 PM
krytarowski edited the summary of this revision. (Show Details)
  • rework the interceptor
krytarowski edited the summary of this revision. (Show Details)
vitalybuka accepted this revision.Dec 7 2018, 1:20 PM
This revision is now accepted and ready to land.Dec 7 2018, 1:20 PM
vitalybuka added inline comments.Dec 7 2018, 1:21 PM
test/sanitizer_common/TestCases/NetBSD/strtoi.cc
70 ↗(On Diff #177109)

could you please make a single test function with arguments
now they are almost identical

krytarowski marked an inline comment as done.Dec 7 2018, 1:23 PM
krytarowski added inline comments.
test/sanitizer_common/TestCases/NetBSD/strtoi.cc
70 ↗(On Diff #177109)

I will do it.

This revision was automatically updated to reflect the committed changes.