llvm.org GIT mirror llvm / 4b4fd78
llvm-undname: Fix out-of-bounds read on invalid intrinsic function code Found by inspection. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358239 91177308-0d34-0410-b5e6-96231b3b80d8 Nico Weber 1 year, 7 months ago
3 changed file(s) with 16 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
206206 NamedIdentifierNode *demangleBackRefName(StringView &MangledName);
207207 IdentifierNode *demangleTemplateInstantiationName(StringView &MangledName,
208208 NameBackrefBehavior NBB);
209 IntrinsicFunctionKind
210 translateIntrinsicFunctionCode(char CH, FunctionIdentifierCodeGroup Group);
209211 IdentifierNode *demangleFunctionIdentifierCode(StringView &MangledName);
210212 IdentifierNode *
211213 demangleFunctionIdentifierCode(StringView &MangledName,
510510 return N;
511511 }
512512
513 static IntrinsicFunctionKind
514 translateIntrinsicFunctionCode(char CH, FunctionIdentifierCodeGroup Group) {
513 IntrinsicFunctionKind
514 Demangler::translateIntrinsicFunctionCode(char CH,
515 FunctionIdentifierCodeGroup Group) {
516 using IFK = IntrinsicFunctionKind;
517 if (!(CH >= '0' && CH <= '9') && !(CH >= 'A' && CH <= 'Z')) {
518 Error = true;
519 return IFK::None;
520 }
521
515522 // Not all ? identifiers are intrinsics *functions*. This function only maps
516523 // operator codes for the special functions, all others are handled elsewhere,
517524 // hence the IFK::None entries in the table.
518 using IFK = IntrinsicFunctionKind;
519525 static IFK Basic[36] = {
520526 IFK::None, // ?0 # Foo::Foo()
521527 IFK::None, // ?1 # Foo::~Foo()
108108 ; CHECK-EMPTY:
109109 ; CHECK-NEXT: ?x@@3PAW
110110 ; CHECK-NEXT: error: Invalid mangled name
111
112 ??}
113 ; CHECK-EMPTY:
114 ; CHECK-NEXT: ??}
115 ; CHECK-NEXT: error: Invalid mangled name