From f01e04d593aa61e094d693a17a37ce8b317a8e32 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Sat, 25 Nov 2006 00:27:12 +0000 Subject: [PATCH] ICU-5514 prevent extension table toUnicode section overflow X-SVN-Rev: 20679 --- icu4c/source/tools/makeconv/gencnvex.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/icu4c/source/tools/makeconv/gencnvex.c b/icu4c/source/tools/makeconv/gencnvex.c index c5fc7d464c3..bccb5fc4d7d 100644 --- a/icu4c/source/tools/makeconv/gencnvex.c +++ b/icu4c/source/tools/makeconv/gencnvex.c @@ -439,17 +439,24 @@ generateToUTable(CnvExtData *extData, UCMTable *table, /* step 2: allocate the section; set count, section */ count=(high-low)+1; - if(unitIndex==0 || uniqueCount>=(3*count)/4) { + if(count<0x100 && (unitIndex==0 || uniqueCount>=(3*count)/4)) { /* * for the root table and for fairly full tables: * allocate for direct, linear array access * by keeping count, to write an entry for each unit value * from low to high + * exception: use a compact table if count==0x100 because + * that cannot be encoded in the length byte */ } else { count=uniqueCount; } + if(count>=0x100) { + fprintf(stderr, "error: toUnicode extension table section overflow: %ld section entries\n", (long)count); + return FALSE; + } + /* allocate the section: 1 entry for the header + count for the items */ section=(uint32_t *)utm_allocN(extData->toUTable, 1+count);