[llvm] r359109 - llvm-undname: Fix assert-on->4GiB-string-literal, found by oss-fuzz

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 24 09:09:39 PDT 2019


Author: nico
Date: Wed Apr 24 09:09:38 2019
New Revision: 359109

URL: http://llvm.org/viewvc/llvm-project?rev=359109&view=rev
Log:
llvm-undname: Fix assert-on->4GiB-string-literal, found by oss-fuzz

Modified:
    llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
    llvm/trunk/test/Demangle/ms-string-literals.test

Modified: llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp?rev=359109&r1=359108&r2=359109&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp (original)
+++ llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp Wed Apr 24 09:09:38 2019
@@ -1154,8 +1154,11 @@ static unsigned countEmbeddedNulls(const
   return Result;
 }
 
+// A mangled (non-wide) string literal stores the total length of the string it
+// refers to (passed in NumBytes), and it contains up to 32 bytes of actual text
+// (passed in StringBytes, NumChars).
 static unsigned guessCharByteSize(const uint8_t *StringBytes, unsigned NumChars,
-                                  unsigned NumBytes) {
+                                  uint64_t NumBytes) {
   assert(NumBytes > 0);
 
   // If the number of bytes is odd, this is guaranteed to be a char string.

Modified: llvm/trunk/test/Demangle/ms-string-literals.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/ms-string-literals.test?rev=359109&r1=359108&r2=359109&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/ms-string-literals.test (original)
+++ llvm/trunk/test/Demangle/ms-string-literals.test Wed Apr 24 09:09:38 2019
@@ -792,3 +792,8 @@
 
 ??_C at _07LJGFEJEB@D3?$CC?$BB?$AA?$AA?$AA?$AA@)
 ; CHECK: U"\x11223344"
+
+; This has a string length of 0x6_0000_0000, so it's 0 if treated as a 32-bit
+; number. (In practice, 24GiB large string literals should be rare.)
+??_C at _0GAAAAAAAA@GPLEPFHO at 01234567890123456789012345678901@
+; CHECK: "01234567890123456789012345678901"...




More information about the llvm-commits mailing list