From 5d2aaca2a9915244ca65e38e1a4485f1ff925512 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Tue, 15 Jun 2010 06:06:24 +0000 Subject: [PATCH] ICU-7167 fix rudimentary CE bytes check in genuca X-SVN-Rev: 28194 --- tools/unicode/c/genuca/genuca.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/unicode/c/genuca/genuca.cpp b/tools/unicode/c/genuca/genuca.cpp index 54545de606..c4d3f435d2 100644 --- a/tools/unicode/c/genuca/genuca.cpp +++ b/tools/unicode/c/genuca/genuca.cpp @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 2000-2009, International Business Machines +* Copyright (C) 2000-2010, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -706,10 +706,8 @@ UCAElements *readAnElement(FILE *data, tempUCATable *t, UCAConstants *consts, UE pointer++; } } - // Check for valid bytes in CE weights. - // TODO: Tighten this so that it allows 03 & 04 in intermediate bytes - // but not in final bytes. - // See http://bugs.icu-project.org/trac/ticket/7167 + // Rudimentary check for valid bytes in CE weights. + // For a more comprehensive check see cintltst /tscoll/citertst/TestCEValidity for (i = 0; i < (int32_t)CEindex; ++i) { uint32_t value = element->CEs[i]; uint8_t bytes[4] = { @@ -719,15 +717,17 @@ UCAElements *readAnElement(FILE *data, tempUCATable *t, UCAConstants *consts, UE (uint8_t)(value & UCOL_NEW_TERTIARYORDERMASK) }; for (int j = 0; j < 4; ++j) { - uint8_t maxByte = - (isContinuation(value) || j == 1) ? - UCOL_BYTE_FIRST_TAILORED : - UCOL_BYTE_COMMON; - if (0 != bytes[j] && bytes[j] < maxByte) { + if (0 != bytes[j] && bytes[j] < 3) { fprintf(stderr, "Warning: invalid UCA weight byte %02X for %s\n", bytes[j], buffer); - // TODO: return NULL; + return NULL; } } + // Primary second bytes 03 and FF are compression terminators. + if (!isContinuation(value) && (bytes[1] == 3 || bytes[1] == 0xFF)) { + fprintf(stderr, "Warning: invalid UCA primary second weight byte %02X for %s\n", + bytes[1], buffer); + return NULL; + } } if(U_FAILURE(*status)) {