From: Abhinav Gupta Date: Tue, 13 Sep 2011 19:14:32 +0000 (+0000) Subject: ICU-8812 fixed init_entry overflow and TestSymbolsWithBadLocale test case X-Git-Tag: milestone-59-0-1~4531 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=728d95f8c9d5f545571bd186d06f9c4580cac525;p=icu ICU-8812 fixed init_entry overflow and TestSymbolsWithBadLocale test case X-SVN-Rev: 30649 --- diff --git a/icu4c/source/common/uresbund.cpp b/icu4c/source/common/uresbund.cpp index 81e31b4a73b..cf1b2a55b85 100644 --- a/icu4c/source/common/uresbund.cpp +++ b/icu4c/source/common/uresbund.cpp @@ -319,7 +319,7 @@ static UResourceDataEntry *init_entry(const char *localeID, const char *path, UE UResourceDataEntry *r = NULL; UResourceDataEntry find; /*int32_t hashValue;*/ - char name[96]; + char name[ULOC_FULLNAME_CAPACITY]; char aliasName[100] = { 0 }; int32_t aliasLen = 0; /*UBool isAlias = FALSE;*/ @@ -335,7 +335,8 @@ static UResourceDataEntry *init_entry(const char *localeID, const char *path, UE } else if(*localeID == 0) { /* if localeID is "" then we try to open root locale */ uprv_strcpy(name, kRootLocaleName); } else { /* otherwise, we'll open what we're given */ - uprv_strcpy(name, localeID); + uprv_strncpy(name, localeID, sizeof(name) - 1); + name[sizeof(name) - 1] = 0; } find.fName = name; diff --git a/icu4c/source/test/intltest/numfmtst.cpp b/icu4c/source/test/intltest/numfmtst.cpp index b101553bf22..3318da43879 100644 --- a/icu4c/source/test/intltest/numfmtst.cpp +++ b/icu4c/source/test/intltest/numfmtst.cpp @@ -1932,8 +1932,8 @@ void NumberFormatTest::TestSymbolsWithBadLocale(void) { Locale::setDefault(locBad, status); logln("Current locale is %s", Locale::getDefault().getName()); DecimalFormatSymbols mySymbols(status); - if (status != U_USING_FALLBACK_WARNING) { - errln("DecimalFormatSymbols should returned U_USING_FALLBACK_WARNING."); + if (status != U_USING_DEFAULT_WARNING) { + errln("DecimalFormatSymbols should returned U_USING_DEFAULT_WARNING."); } if (strcmp(mySymbols.getLocale().getName(), locBad.getName()) != 0) { errln("DecimalFormatSymbols does not have the right locale.");