From 4c80e2649e6eeb70b174a98c39a3a169a134b598 Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Tue, 28 Mar 2006 08:52:36 +0000 Subject: [PATCH] ICU-4703 Fix u_errorName bounds checking. X-SVN-Rev: 19465 --- icu4c/source/common/unicode/utypes.h | 6 +++--- icu4c/source/common/utypes.c | 7 ++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/icu4c/source/common/unicode/utypes.h b/icu4c/source/common/unicode/utypes.h index 207821f805a..d6b30119b9e 100644 --- a/icu4c/source/common/unicode/utypes.h +++ b/icu4c/source/common/unicode/utypes.h @@ -684,8 +684,8 @@ typedef enum UErrorCode { /* * the error code range 0x10200 0x102ff are reserved for Break Iterator related error */ + U_BRK_INTERNAL_ERROR=0x10200, /**< An internal error (bug) was detected. */ U_BRK_ERROR_START=0x10200, /**< Start of codes indicating Break Iterator failures */ - U_BRK_INTERNAL_ERROR, /**< An internal error (bug) was detected. */ U_BRK_HEX_DIGITS_EXPECTED, /**< Hex digits expected as part of a escaped char in a rule. */ U_BRK_SEMICOLON_EXPECTED, /**< Missing ';' at the end of a RBBI rule. */ U_BRK_RULE_SYNTAX, /**< Syntax error in RBBI rule. */ @@ -704,8 +704,8 @@ typedef enum UErrorCode { /* * The error codes in the range 0x10300-0x103ff are reserved for regular expression related errrs */ + U_REGEX_INTERNAL_ERROR=0x10300, /**< An internal error (bug) was detected. */ U_REGEX_ERROR_START=0x10300, /**< Start of codes indicating Regexp failures */ - U_REGEX_INTERNAL_ERROR, /**< An internal error (bug) was detected. */ U_REGEX_RULE_SYNTAX, /**< Syntax error in regexp pattern. */ U_REGEX_INVALID_STATE, /**< RegexMatcher in invalid state for requested operation */ U_REGEX_BAD_ESCAPE_SEQUENCE, /**< Unrecognized backslash escape sequence in pattern */ @@ -724,8 +724,8 @@ typedef enum UErrorCode { /* * The error code in the range 0x10400-0x104ff are reserved for IDNA related error codes */ + U_IDNA_PROHIBITED_ERROR=0x10400, U_IDNA_ERROR_START=0x10400, - U_IDNA_PROHIBITED_ERROR, U_IDNA_UNASSIGNED_ERROR, U_IDNA_CHECK_BIDI_ERROR, U_IDNA_STD3_ASCII_RULES_ERROR, diff --git a/icu4c/source/common/utypes.c b/icu4c/source/common/utypes.c index cef645a7726..2255b0c1b73 100644 --- a/icu4c/source/common/utypes.c +++ b/icu4c/source/common/utypes.c @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 1997-2005, International Business Machines +* Copyright (C) 1997-2006, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -121,7 +121,6 @@ _uFmtErrorName[U_FMT_PARSE_ERROR_LIMIT - U_FMT_PARSE_ERROR_START] = { static const char * const _uBrkErrorName[U_BRK_ERROR_LIMIT - U_BRK_ERROR_START] = { - "U_BRK_ERROR_START", "U_BRK_INTERNAL_ERROR", "U_BRK_HEX_DIGITS_EXPECTED", "U_BRK_SEMICOLON_EXPECTED", @@ -140,7 +139,6 @@ _uBrkErrorName[U_BRK_ERROR_LIMIT - U_BRK_ERROR_START] = { static const char * const _uRegexErrorName[U_REGEX_ERROR_LIMIT - U_REGEX_ERROR_START] = { - "U_REGEX_ERROR_START", "U_REGEX_INTERNAL_ERROR", "U_REGEX_RULE_SYNTAX", "U_REGEX_INVALID_STATE", @@ -159,7 +157,6 @@ _uRegexErrorName[U_REGEX_ERROR_LIMIT - U_REGEX_ERROR_START] = { static const char * const _uIDNAErrorName[U_IDNA_ERROR_LIMIT - U_IDNA_ERROR_START] = { - "U_IDNA_ERROR_START", "U_STRINGPREP_PROHIBITED_ERROR", "U_STRINGPREP_UNASSIGNED_ERROR", "U_STRINGPREP_CHECK_BIDI_ERROR", @@ -184,7 +181,7 @@ u_errorName(UErrorCode code) { return _uBrkErrorName[code - U_BRK_ERROR_START]; } else if (U_REGEX_ERROR_START <= code && code < U_REGEX_ERROR_LIMIT) { return _uRegexErrorName[code - U_REGEX_ERROR_START]; - } else if( U_IDNA_ERROR_START <= code && code <= U_IDNA_ERROR_LIMIT) { + } else if(U_IDNA_ERROR_START <= code && code < U_IDNA_ERROR_LIMIT) { return _uIDNAErrorName[code - U_IDNA_ERROR_START]; } else { return "[BOGUS UErrorCode]";