]> granicus.if.org Git - icu/commitdiff
ICU-10250 fix an error in _getKeywords()
authorJungshik Shin <jshin@chromium.org>
Wed, 21 Aug 2013 23:51:56 +0000 (23:51 +0000)
committerJungshik Shin <jshin@chromium.org>
Wed, 21 Aug 2013 23:51:56 +0000 (23:51 +0000)
X-SVN-Rev: 34078

icu4c/source/common/uloc.cpp

index 66905b022f3561e18332e09a08cf51b152653e6e..971ed062ab63bfee56c9bcee9f4c9190a7855559 100644 (file)
@@ -678,6 +678,13 @@ _getKeywords(const char *localeID,
                     keywordList[numKeywords].keyword[n++] = uprv_tolower(pos[i]);
                 }
             }
+
+            /* zero-length keyword is an error. */
+            if (n == 0) {
+                *status = U_INVALID_FORMAT_ERROR;
+                return 0;
+            }
+
             keywordList[numKeywords].keyword[n] = 0;
             keywordList[numKeywords].keywordLen = n;
             /* now grab the value part. First we skip the '=' */
@@ -686,8 +693,15 @@ _getKeywords(const char *localeID,
             while(*equalSign == ' ') {
                 equalSign++;
             }
+
+            /* Premature end or zero-length value */
+            if (!equalSign || equalSign == semicolon) {
+                *status = U_INVALID_FORMAT_ERROR;
+                return 0;
+            }
+
             keywordList[numKeywords].valueStart = equalSign;
-            
+
             pos = semicolon;
             i = 0;
             if(pos) {