@@ -1848,40 +1848,34 @@ void StringCaseTest::TestCaseMapGreekExtended() {
18481848#endif
18491849}
18501850
1851- void StringCaseTest::TestCmpFoldStackBufferUnderflow () {
1852- UErrorCode errorCode = U_ZERO_ERROR ;
18531851
1852+ void StringCaseTest::TestCmpFoldStackBufferUnderflow () {
18541853 // Surrogate/Supplementary sequence constructed from V8 PoC targeting the _cmpFold boundary edge-case.
18551854 // Includes a standalone lead surrogate followed immediately by a supplementary character case-folding trigger.
1856- static const char16_t s1 [] = {
1855+ static const char16_t s1_chars [] = {
18571856 0xd801 , // Standalone / Intervening Lead Surrogate
18581857 0xd801 , 0xdc01 , // U+10401 (Lead + Trail) -> Generates 'fold' entry at absolute zero-index boundary
18591858 0xd801 , 0xdc01 ,
18601859 0xdc02 , // Trail Surrogate boundary anchor
18611860 0
18621861 };
18631862
1864- static const char16_t s2 [] = {
1863+ static const char16_t s2_chars [] = {
18651864 0xd801 , 0xdc01 ,
18661865 0xd801 , 0xdc01 ,
18671866 0xd801 , 0xdc02 ,
18681867 0
18691868 };
18701869
1871- // Execute u_strcmpFold. Under ASAN on an unpatched binary, this immediately
1872- // triggers a stack-buffer-overflow read underflow at fold1[-1].
1873- int32_t cmpResult = u_strcmpFold (
1874- s1, -1 ,
1875- s2, -1 ,
1876- U_FOLD_CASE_DEFAULT ,
1877- &errorCode
1878- );
1870+ // Construct immutable UnicodeString wrappers leveraging ICU's public C++ API.
1871+ icu::UnicodeString s1 (false , s1_chars, -1 );
1872+ icu::UnicodeString s2 (false , s2_chars, -1 );
18791873
1880- // Assert that execution completes without error-state propagation and
1881- // terminates deterministically, demonstrating robust stack-boundary enforcement .
1882- assertSuccess ( " u_strcmpFold stack-underflow boundary check " , errorCode );
1874+ // Execute the case-folded comparison. This internally delegates to the
1875+ // version-renamed u_strcmpFold (and underlying _cmpFold), securely exercising the patched stack boundaries .
1876+ int8_t cmpResult = s1. caseCompare (s2, U_FOLD_CASE_DEFAULT );
18831877
1884- // Result value utilized to enforce runtime evaluation
1878+ // Validate deterministic completion and memory-safety boundary execution.
18851879 (void )cmpResult;
18861880}
18871881
0 commit comments