[llvm] r358852 - llvm-undname: Fix stack overflow on invalid found by oss-fuzz
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 21 07:25:07 PDT 2019
Author: nico
Date: Sun Apr 21 07:25:07 2019
New Revision: 358852
URL: http://llvm.org/viewvc/llvm-project?rev=358852&view=rev
Log:
llvm-undname: Fix stack overflow on invalid found by oss-fuzz
Modified:
llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
llvm/trunk/test/Demangle/invalid-manglings.test
Modified: llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp?rev=358852&r1=358851&r2=358852&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp (original)
+++ llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp Sun Apr 21 07:25:07 2019
@@ -1292,7 +1292,7 @@ Demangler::demangleStringLiteral(StringV
unsigned BytesDecoded = 0;
while (!MangledName.consumeFront('@')) {
- if (MangledName.size() < 1)
+ if (MangledName.size() < 1 || BytesDecoded >= MaxStringByteLength)
goto StringLiteralError;
StringBytes[BytesDecoded++] = demangleCharLiteral(MangledName);
}
Modified: llvm/trunk/test/Demangle/invalid-manglings.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/invalid-manglings.test?rev=358852&r1=358851&r2=358852&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/invalid-manglings.test (original)
+++ llvm/trunk/test/Demangle/invalid-manglings.test Sun Apr 21 07:25:07 2019
@@ -159,3 +159,8 @@
; CHECK-EMPTY:
; CHECK-NEXT: ??_C at _1301234567@a
; CHECK-NEXT: error: Invalid mangled name
+
+??_C at _0601234567@abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRTSUVWXYZabcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRTSUVWXYZabcdefghijklmnopqrtsuvwxyz
+; CHECK-EMPTY:
+; CHECK-NEXT: ??_C at _0601234567@abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRTSUVWXYZabcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRTSUVWXYZabcdefghijklmnopqrtsuvwxyz
+; CHECK-NEXT: error: Invalid mangled name
More information about the llvm-commits
mailing list