From c207e27745273a959bc0ce90ab001ae23e2ab52e Mon Sep 17 00:00:00 2001 From: Jungshik Shin Date: Wed, 21 Aug 2013 23:51:56 +0000 Subject: [PATCH] ICU-10250 fix an error in _getKeywords() X-SVN-Rev: 34078 --- icu4c/source/common/uloc.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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) { -- 2.40.0