From: Jungshik Shin Date: Wed, 21 Aug 2013 23:51:56 +0000 (+0000) Subject: ICU-10250 fix an error in _getKeywords() X-Git-Tag: milestone-59-0-1~2688 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c207e27745273a959bc0ce90ab001ae23e2ab52e;p=icu ICU-10250 fix an error in _getKeywords() X-SVN-Rev: 34078 --- diff --git a/icu4c/source/common/uloc.cpp b/icu4c/source/common/uloc.cpp index 66905b022f3..971ed062ab6 100644 --- a/icu4c/source/common/uloc.cpp +++ b/icu4c/source/common/uloc.cpp @@ -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) {