[PATCH] D94950: [clang][lex] Speculative fix for buffer overrun on raw string parse

2021-02-23 Thread Brent Royal-Gordon via Phabricator via cfe-commits
brentdax accepted this revision.
brentdax added a comment.
This revision is now accepted and ready to land.

Looks good. Thanks for implementing this!




Comment at: clang/lib/Lex/LiteralSupport.cpp:1647
   ThisTokEnd -= ThisTokBuf - Prefix;
   assert(ThisTokEnd >= ThisTokBuf && "malformed raw string literal");
 

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.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94950/new/

https://reviews.llvm.org/D94950

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94950: [clang][lex] Speculative fix for buffer overrun on raw string parse

2021-02-23 Thread Brent Royal-Gordon via Phabricator via cfe-commits
brentdax added inline comments.



Comment at: clang/lib/Lex/LiteralSupport.cpp:1639
   const char *Prefix = ThisTokBuf;
-  while (ThisTokBuf[0] != '(')
+  while (ThisTokBuf - Prefix < 16 && ThisTokBuf[0] != '(')
 ++ThisTokBuf;

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.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94950/new/

https://reviews.llvm.org/D94950

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits