]> granicus.if.org Git - llvm/commitdiff
llvm-undname: Fix assert-on->4GiB-string-literal, found by oss-fuzz
authorNico Weber <nicolasweber@gmx.de>
Wed, 24 Apr 2019 16:09:38 +0000 (16:09 +0000)
committerNico Weber <nicolasweber@gmx.de>
Wed, 24 Apr 2019 16:09:38 +0000 (16:09 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359109 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Demangle/MicrosoftDemangle.cpp
test/Demangle/ms-string-literals.test

index 14c6e1e5ef5db2d2e5299d1ee24aebccd3e57dff..4942e0e3655e51326182e327e4647ded6e59ad17 100644 (file)
@@ -1154,8 +1154,11 @@ static unsigned countEmbeddedNulls(const uint8_t *StringBytes,
   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.
index 0e9d1edea8a4b2be8fcdb42fbd1dccada3b709e5..43c03c1c51e70be9de93c665ac9df4ff8d1699e8 100644 (file)
 
 ??_C@_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@_0GAAAAAAAA@GPLEPFHO@01234567890123456789012345678901@
+; CHECK: "01234567890123456789012345678901"...