Page MenuHomePhabricator

Protect against filenames with no extension at all.

Authored by saugustine on Aug 4 2020, 11:27 AM.



Such as the one in the darwin-dsymutil.c test.

Diff Detail

Event Timeline

saugustine created this revision.Aug 4 2020, 11:27 AM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: cfe-commits. · View Herald Transcript
saugustine requested review of this revision.Aug 4 2020, 11:27 AM

Can you add a test that exercises this code path?

The darwin-dsymutil.c tests this code path right now on line 33. I found this error by running it under asan; otherwise it was fully latent.

It seems pretty clear to me that when End == -1 (StringRef::npos), creating a string ref from that is obviously a bug.

I'm not even sure how to check for a failure. clang will almost never crash; there is just a very subtle bounds violation or empty stringref. How it manifests itself depends on subsequent usage of the stringref, and stack layout.

Could maybe add an assert along with the patch as well as an assert only

saugustine abandoned this revision.Sep 10 2020, 9:46 AM