|
| 1 | +From aa17de1994d188560d99d07c37bf333416483899 Mon Sep 17 00:00:00 2001 |
| 2 | +From: George Rhoten <grhoten@users.noreply.github.com> |
| 3 | +Date: Tue, 18 Nov 2025 15:47:24 -0800 |
| 4 | +Subject: [PATCH] ICU-23263 Support shared/static data library that uses a |
| 5 | + pointer based table of contents |
| 6 | + |
| 7 | +--- |
| 8 | + icu4c/source/common/ucnv_io.cpp | 7 ++++--- |
| 9 | + icu4c/source/configure | 2 +- |
| 10 | + icu4c/source/configure.ac | 2 +- |
| 11 | + 3 files changed, 6 insertions(+), 5 deletions(-) |
| 12 | + |
| 13 | +diff --git a/icu4c/source/common/ucnv_io.cpp b/icu4c/source/common/ucnv_io.cpp |
| 14 | +index 46a26f821fd8..66813f5a0372 100644 |
| 15 | +--- a/icu4c/source/common/ucnv_io.cpp |
| 16 | ++++ b/icu4c/source/common/ucnv_io.cpp |
| 17 | +@@ -249,14 +249,15 @@ static void U_CALLCONV initAliasData(UErrorCode &errCode) { |
| 18 | + |
| 19 | + sectionSizes = static_cast<const uint32_t*>(udata_getMemory(data)); |
| 20 | + int32_t dataLength = udata_getLength(data); // This is the length minus the UDataInfo size |
| 21 | +- if (dataLength <= int32_t(sizeof(sectionSizes[0]))) { |
| 22 | ++ UBool isDataLengthKnown = dataLength >= 0; // Only false when using a pointer table of contents (not files nor a common data archive) |
| 23 | ++ if (isDataLengthKnown && dataLength <= int32_t(sizeof(sectionSizes[0]))) { |
| 24 | + // We don't even have a TOC! |
| 25 | + goto invalidFormat; |
| 26 | + } |
| 27 | + table = reinterpret_cast<const uint16_t*>(sectionSizes); |
| 28 | + tableStart = sectionSizes[0]; |
| 29 | + sizeOfTOC = int32_t((tableStart + 1) * sizeof(sectionSizes[0])); |
| 30 | +- if (tableStart < minTocLength || dataLength <= sizeOfTOC) { |
| 31 | ++ if (tableStart < minTocLength || (isDataLengthKnown && dataLength <= sizeOfTOC)) { |
| 32 | + // We don't have a whole TOC! |
| 33 | + goto invalidFormat; |
| 34 | + } |
| 35 | +@@ -279,7 +280,7 @@ static void U_CALLCONV initAliasData(UErrorCode &errCode) { |
| 36 | + for (uint32_t section = 1; section <= tableStart; section++) { |
| 37 | + sizeOfData += sectionSizes[section] * sizeof(table[0]); |
| 38 | + } |
| 39 | +- if (dataLength < sizeOfData) { |
| 40 | ++ if (isDataLengthKnown && dataLength < sizeOfData) { |
| 41 | + // Truncated file! |
| 42 | + goto invalidFormat; |
| 43 | + } |
0 commit comments