From 95a8083095e58522870dca380dd4275d9da9ee83 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Wed, 3 Jan 2001 00:30:31 +0000 Subject: [PATCH] ICU-701 add code to test if a subchar byte sequence is valid in the codepage structure X-SVN-Rev: 3365 --- icu4c/source/tools/makeconv/makeconv.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/icu4c/source/tools/makeconv/makeconv.c b/icu4c/source/tools/makeconv/makeconv.c index 116b7ba58f..df8f8a70f9 100644 --- a/icu4c/source/tools/makeconv/makeconv.c +++ b/icu4c/source/tools/makeconv/makeconv.c @@ -676,6 +676,24 @@ void loadTableFromFile(FileStream* convFile, UConverterSharedData* sharedData, U } } + if(cnvData->isValid!=NULL) + { + const uint8_t *p = staticData->subChar; + codepageValue = 0; + switch(staticData->subCharLen) { + case 4: codepageValue = (codepageValue << 8) | *p++; + case 3: codepageValue = (codepageValue << 8) | *p++; + case 2: codepageValue = (codepageValue << 8) | *p++; + case 1: codepageValue = (codepageValue << 8) | *p; + default: break; /* must never occur */ + } + if(!cnvData->isValid(cnvData, staticData->subChar, staticData->subCharLen, codepageValue)) { + fprintf(stderr, " the substitution character byte sequence is illegal in this codepage structure!\n"); + *err = U_INVALID_TABLE_FORMAT; + isOK = FALSE; + } + } + staticData->hasFromUnicodeFallback = staticData->hasToUnicodeFallback = FALSE; while (T_FileStream_readLine(convFile, storageLine, sizeof(storageLine)))