llvm.org GIT mirror llvm / a329ade
llvm-undname: Fix two more asserts-on-invalid, found by oss-fuzz git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358708 91177308-0d34-0410-b5e6-96231b3b80d8 Nico Weber 1 year, 7 months ago
2 changed file(s) with 14 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
981981 }
982982
983983 uint8_t Demangler::demangleCharLiteral(StringView &MangledName) {
984 assert(!MangledName.empty());
984985 if (!MangledName.startsWith('?'))
985986 return MangledName.popFront();
986987
12471248
12481249 // Encoded Length
12491250 std::tie(StringByteSize, IsNegative) = demangleNumber(MangledName);
1250 if (Error || IsNegative)
1251 if (Error || IsNegative || StringByteSize < (IsWcharT ? 2 : 1))
12511252 goto StringLiteralError;
12521253
12531254 // CRC 32 (always 8 characters plus a terminator)
12681269 Result->IsTruncated = true;
12691270
12701271 while (!MangledName.consumeFront('@')) {
1271 if (StringByteSize < 2)
1272 if (MangledName.size() < 2)
12721273 goto StringLiteralError;
12731274 wchar_t W = demangleWcharLiteral(MangledName);
12741275 if (StringByteSize != 2 || Result->IsTruncated)
12851286
12861287 unsigned BytesDecoded = 0;
12871288 while (!MangledName.consumeFront('@')) {
1288 if (StringByteSize < 1)
1289 if (MangledName.size() < 1)
12891290 goto StringLiteralError;
12901291 StringBytes[BytesDecoded++] = demangleCharLiteral(MangledName);
12911292 }
148148 ; CHECK-EMPTY:
149149 ; CHECK-NEXT: ??_C@_1A@01234567@a
150150 ; CHECK-NEXT: error: Invalid mangled name
151
152 ??_C@_0301234567@a
153 ; CHECK-EMPTY:
154 ; CHECK-NEXT: ??_C@_0301234567@a
155 ; CHECK-NEXT: error: Invalid mangled name
156
157 ??_C@_1301234567@a
158 ; CHECK-EMPTY:
159 ; CHECK-NEXT: ??_C@_1301234567@a
160 ; CHECK-NEXT: error: Invalid mangled name