Skip to content

Cherry-pick: ICU-21449 Infinite loop can occur with locale IDs containing RES_PATH_SEPARATOR - #66

Merged
Erin Genovy (jefgen) merged 1 commit into
masterfrom
user/jefgen/cp-ICU-21449-infinite-loop
Feb 1, 2021
Merged

Erin Genovy (jefgen) merged 1 commit into
masterfrom
user/jefgen/cp-ICU-21449-infinite-loop

Conversation

@jefgen

Copy link
Copy Markdown
Member

This change cherry-picks the upstream fix for the issue of an infinite loop when calling various APIs with locale IDs that contain RES_PATH_SEPARATOR.

Upstream ticket:
https://unicode-org.atlassian.net/browse/ICU-21449

Upstream PR:
unicode-org/icu#1549

Summary

PR Checklist

  • I have verified that my change is specific to this fork and cannot be made upstream.
  • I am making a maintenance related change.
  • I am making a change that is related to usage internal to Microsoft.
  • I am making a change that is related to the Windows OS build of ICU.
  • CLA signed. If not, please see here to sign the CLA.

Detailed Description

From the upstream PR:

When calling APIs like uloc_getDisplayLanguage, if the input locale ID has / (the RES_PATH_SEPARATOR value) then the resource look-up code ends up in an infinite loop.

For example, the following code will never return:

UErrorCode status = U_ZERO_ERROR;
const char* localeNameTemp = "/"; // RES_PATH_SEPARATOR
uloc_getDisplayLanguage(localeNameTemp, localeNameTemp, NULL, 0, &status);

The do {...} while loop in ures_getByKeyWithFallback calls res_findResource, but it never checks to see if the returned resource is RES_BOGUS, meaning that for some paths it will never terminate. (Thanks to am11 for doing the initial investigation into this issue.)

This PR also includes a test case for the issue. Note that there is nothing really "tested" by the test case, as the test is to simply ensure that calling the API doesn't cause a hang due to the infinite loop.

@jefgen
Erin Genovy (jefgen) merged commit 8912565 into master Feb 1, 2021
@jefgen
Erin Genovy (jefgen) deleted the user/jefgen/cp-ICU-21449-infinite-loop branch February 1, 2021 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants