[llvm] r358239 - llvm-undname: Fix out-of-bounds read on invalid intrinsic function code
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 11 16:11:33 PDT 2019
Author: nico
Date: Thu Apr 11 16:11:33 2019
New Revision: 358239
URL: http://llvm.org/viewvc/llvm-project?rev=358239&view=rev
Log:
llvm-undname: Fix out-of-bounds read on invalid intrinsic function code
Found by inspection.
Modified:
llvm/trunk/include/llvm/Demangle/MicrosoftDemangle.h
llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
llvm/trunk/test/Demangle/invalid-manglings.test
Modified: llvm/trunk/include/llvm/Demangle/MicrosoftDemangle.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Demangle/MicrosoftDemangle.h?rev=358239&r1=358238&r2=358239&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Demangle/MicrosoftDemangle.h (original)
+++ llvm/trunk/include/llvm/Demangle/MicrosoftDemangle.h Thu Apr 11 16:11:33 2019
@@ -207,6 +207,8 @@ private:
NamedIdentifierNode *demangleBackRefName(StringView &MangledName);
IdentifierNode *demangleTemplateInstantiationName(StringView &MangledName,
NameBackrefBehavior NBB);
+ IntrinsicFunctionKind
+ translateIntrinsicFunctionCode(char CH, FunctionIdentifierCodeGroup Group);
IdentifierNode *demangleFunctionIdentifierCode(StringView &MangledName);
IdentifierNode *
demangleFunctionIdentifierCode(StringView &MangledName,
Modified: llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp?rev=358239&r1=358238&r2=358239&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp (original)
+++ llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp Thu Apr 11 16:11:33 2019
@@ -511,12 +511,18 @@ Demangler::demangleLiteralOperatorIdenti
return N;
}
-static IntrinsicFunctionKind
-translateIntrinsicFunctionCode(char CH, FunctionIdentifierCodeGroup Group) {
+IntrinsicFunctionKind
+Demangler::translateIntrinsicFunctionCode(char CH,
+ FunctionIdentifierCodeGroup Group) {
+ using IFK = IntrinsicFunctionKind;
+ if (!(CH >= '0' && CH <= '9') && !(CH >= 'A' && CH <= 'Z')) {
+ Error = true;
+ return IFK::None;
+ }
+
// Not all ? identifiers are intrinsics *functions*. This function only maps
// operator codes for the special functions, all others are handled elsewhere,
// hence the IFK::None entries in the table.
- using IFK = IntrinsicFunctionKind;
static IFK Basic[36] = {
IFK::None, // ?0 # Foo::Foo()
IFK::None, // ?1 # Foo::~Foo()
Modified: llvm/trunk/test/Demangle/invalid-manglings.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/invalid-manglings.test?rev=358239&r1=358238&r2=358239&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/invalid-manglings.test (original)
+++ llvm/trunk/test/Demangle/invalid-manglings.test Thu Apr 11 16:11:33 2019
@@ -109,3 +109,8 @@
; CHECK-EMPTY:
; CHECK-NEXT: ?x@@3PAW
; CHECK-NEXT: error: Invalid mangled name
+
+??}
+; CHECK-EMPTY:
+; CHECK-NEXT: ??}
+; CHECK-NEXT: error: Invalid mangled name
More information about the llvm-commits
mailing list