This is an archive of the discontinued LLVM Phabricator instance.

[clang][lex] Speculative fix for buffer overrun on raw string parse
ClosedPublic

Authored by jansvoboda11 on Jan 19 2021, 12:33 AM.

Details

Summary

This attempts to fix a (non-deterministic) buffer overrun when parsing raw string literals during modular build.

Similar fix to 4e5b5c36f47c9a406ea7f6b4f89fae477693973a.

Diff Detail

Event Timeline

jansvoboda11 requested review of this revision.Jan 19 2021, 12:33 AM
jansvoboda11 created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 19 2021, 12:33 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jansvoboda11 retitled this revision from [clang] Speculative fix for buffer overrun on raw string parse to [clang][lex] Speculative fix for buffer overrun on raw string parse.Jan 26 2021, 11:59 PM
beccadax accepted this revision.Feb 23 2021, 1:58 PM

Looks good. Thanks for implementing this!

clang/lib/Lex/LiteralSupport.cpp
1651–1652

In your shoes, I would also have promoted this to a real check, but if you think that's overkill I'm fine with leaving it as it is.

This revision is now accepted and ready to land.Feb 23 2021, 1:58 PM
beccadax added inline comments.Feb 23 2021, 2:05 PM
clang/lib/Lex/LiteralSupport.cpp
1643

Nit: "16" is a magic number; it might be better to use a constant or comment to document its significance (raw strings can only have 16-character delimiters).

(I believe this is C++11 [lex.string]p2, but I've never written one of the citation comments you see in clang, so I'm not sure if you should cite a later standard.)

Implement suggested improvements

clang/lib/Lex/LiteralSupport.cpp
1643

Good point on the magic number, I'm going to extract that.

I'll check how the citations are written and add one here.

1651–1652

I think that's sensible, thanks!

This revision was landed with ongoing or failed builds.Mar 15 2021, 7:15 AM
This revision was automatically updated to reflect the committed changes.