This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Always initialize the regex in the regcomp() interceptor
ClosedPublic

Authored by tavianator on Feb 25 2022, 1:51 PM.

Details

Summary

When regcomp() fails, the same regex_t* should be passed to regerror()
for potentially better error messages. But doing that with msan would
report a use-of-uninitialized-value.

Fixes https://github.com/google/sanitizers/issues/1496

Diff Detail

Event Timeline

tavianator requested review of this revision.Feb 25 2022, 1:51 PM
tavianator created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 25 2022, 1:51 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
vitalybuka accepted this revision.Feb 25 2022, 3:12 PM

Thank you!
I can land it later, if you have no access.

compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
7978
compiler-rt/test/sanitizer_common/TestCases/Posix/regex.cpp
44–48

you don't need to move them, just use {} to make sure it's two different instances

This revision is now accepted and ready to land.Feb 25 2022, 3:12 PM

Address review comments

vitalybuka added inline comments.Mar 15 2022, 2:26 PM
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
7977–7978

FYI: the patch is upload somehow incorrectly, "before" does not match existing code. if (!res) is missing.
Arcanist, as explained here https://llvm.org/docs/Phabricator.html#id7, is easy way to upload it correctly.
No need to fix this one, I resolved conflicts already.

Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2022, 2:26 PM

fixed conflicts

This revision was landed with ongoing or failed builds.Mar 15 2022, 2:31 PM
This revision was automatically updated to reflect the committed changes.