[libcxx-commits] [libcxxabi] [ItaniumDemangle] reject A-F in FP literals (PR #82864)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Feb 23 19:56:11 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxxabi
Author: Ryan Prichard (rprichard)
<details>
<summary>Changes</summary>
The Itanium C++ ABI specifies that FP literals are encoded using a lowercase hexadecimal string. Previously, libc++abi allowed uppercase A-F characters but decoded them by subtracting 'a' from them, producing negative digit values. It is especially confusing to accept an 'E' digit because 'E' marks the end of the FP literal.
---
Full diff: https://github.com/llvm/llvm-project/pull/82864.diff
2 Files Affected:
- (modified) libcxxabi/src/demangle/ItaniumDemangle.h (+2-1)
- (modified) libcxxabi/test/test_demangle.pass.cpp (+5-3)
``````````diff
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index 04755e2be3c5d4..be796adc9952d8 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -5541,7 +5541,8 @@ Node *AbstractManglingParser<Alloc, Derived>::parseFloatingLiteral() {
return nullptr;
std::string_view Data(First, N);
for (char C : Data)
- if (!std::isxdigit(C))
+ if (!(C >= '0' && C <= '9') &&
+ !(C >= 'a' && C <= 'f'))
return nullptr;
First += N;
if (!consumeIf('E'))
diff --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp
index b7e41099ebfc53..9bf69f56395285 100644
--- a/libcxxabi/test/test_demangle.pass.cpp
+++ b/libcxxabi/test/test_demangle.pass.cpp
@@ -30222,9 +30222,9 @@ struct FPLiteralCase {
}},
#endif
#if LDBL_FP128
- // This was found by libFuzzer+HWASan on aarch64 Android.
- {"1\006ILeeeEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE",
- {"\x6<-0x1.cecececececececececececececep+11983L>"}},
+ // A 32-character FP literal of long double type
+ {"3FooILeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeEE",
+ {"Foo<-0x1.eeeeeeeeeeeeeeeeeeeeeeeeeeeep+12015L>"}},
#endif
};
const unsigned NF = sizeof(fp_literal_cases) / sizeof(fp_literal_cases[0]);
@@ -30238,6 +30238,8 @@ const char* invalid_cases[] =
"NSoERj5E=Y1[uM:ga",
"Aon_PmKVPDk7?fg4XP5smMUL6;<WsI_mgbf23cCgsHbT<l8EE\0uVRkNOoXDrgdA4[8IU>Vl<>IL8ayHpiVDDDXTY;^o9;i",
"_ZNSt16allocator_traitsISaIN4llvm3sys2fs18directory_iteratorEEE9constructIS3_IS3_EEEDTcl12_S_constructfp_fp0_spcl7forwardIT0_Efp1_EEERS4_PT_DpOS7_",
+ "3FooILdaaaaaaaaaaAAAAaaEE",
+ "3FooILdaaaaaaaaaaaaaaEE",
#if !LDBL_FP80
"_ZN5test01hIfEEvRAcvjplstT_Le4001a000000000000000E_c",
#endif
``````````
</details>
https://github.com/llvm/llvm-project/pull/82864
More information about the libcxx-commits
mailing list