]> granicus.if.org Git - icu/commitdiff
ICU-8812 fixed init_entry overflow and TestSymbolsWithBadLocale test case
authorAbhinav Gupta <mail@abhinavg.net>
Tue, 13 Sep 2011 19:14:32 +0000 (19:14 +0000)
committerAbhinav Gupta <mail@abhinavg.net>
Tue, 13 Sep 2011 19:14:32 +0000 (19:14 +0000)
X-SVN-Rev: 30649

icu4c/source/common/uresbund.cpp
icu4c/source/test/intltest/numfmtst.cpp

index 81e31b4a73b67a4b5d35d79e1d6a57fb39df4471..cf1b2a55b85b7d7c4b42ca2b259d6357fa8f2813 100644 (file)
@@ -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;
index b101553bf2222fde33c55e756dda41e824239a7c..3318da43879577807ba7fd61f75860477d2c9973 100644 (file)
@@ -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.");