This is an archive of the discontinued LLVM Phabricator instance.

Add new interceptor for regex(3) in NetBSD
ClosedPublic

Authored by krytarowski on Nov 15 2018, 9:09 AM.

Details

Summary

Add interceptors for the NetBSD style of regex(3) present inside libc:

  • regcomp
  • regexec
  • regerror
  • regfree
  • regnsub
  • regasub

Add a dedicated test verifying the installed interceptors.

Diff Detail

Event Timeline

krytarowski created this revision.Nov 15 2018, 9:09 AM
vitalybuka added inline comments.Nov 19 2018, 12:47 PM
lib/sanitizer_common/sanitizer_common_interceptors.inc
7299

if REAL failed, string may be not null terminated, so strlen will crash

7316

I can't find documentation for regnsub

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 marked 2 inline comments as done.Dec 3 2018, 5:18 PM
krytarowski added inline comments.
lib/sanitizer_common/sanitizer_common_interceptors.inc
7299

(At least the NetBSD version of) regerror(3) never fails and always returns a string where strlen(3) works.

Actually I can use its value as size to call COMMON_INTERCEPTOR_WRITE_RANGE().

7316
  • enhance patch
vitalybuka accepted this revision.Dec 3 2018, 5:36 PM

LGTM

test/sanitizer_common/TestCases/NetBSD/regex.cc
16

asserts?

This revision is now accepted and ready to land.Dec 3 2018, 5:36 PM
krytarowski marked 2 inline comments as done.
krytarowski added inline comments.
test/sanitizer_common/TestCases/NetBSD/regex.cc
16

I've decided to go for abort() as it's always compiled-in.

This revision was automatically updated to reflect the committed changes.