diff options
Diffstat (limited to 'chromium/third_party/icu/source/common/putil.cpp')
-rw-r--r-- | chromium/third_party/icu/source/common/putil.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/chromium/third_party/icu/source/common/putil.cpp b/chromium/third_party/icu/source/common/putil.cpp index ab904af20ac..42e8be1170a 100644 --- a/chromium/third_party/icu/source/common/putil.cpp +++ b/chromium/third_party/icu/source/common/putil.cpp @@ -722,7 +722,7 @@ extern U_IMPORT char *U_TZNAME[]; #include <dirent.h> /* Needed to search through system timezone files */ #endif static char gTimeZoneBuffer[PATH_MAX]; -static const char *gTimeZoneBufferPtr = nullptr; +static char *gTimeZoneBufferPtr = nullptr; #endif #if !U_PLATFORM_USES_ONLY_WIN32_API @@ -1171,16 +1171,15 @@ uprv_tzname(int n) because the tzfile contents is underspecified. This isn't guaranteed to work because it may not be a symlink. */ - char *ret = realpath(TZDEFAULT, gTimeZoneBuffer); - if (ret != nullptr && uprv_strcmp(TZDEFAULT, gTimeZoneBuffer) != 0) { + int32_t ret = (int32_t)readlink(TZDEFAULT, gTimeZoneBuffer, sizeof(gTimeZoneBuffer)-1); + if (0 < ret) { int32_t tzZoneInfoTailLen = uprv_strlen(TZZONEINFOTAIL); - const char *tzZoneInfoTailPtr = uprv_strstr(gTimeZoneBuffer, TZZONEINFOTAIL); - if (tzZoneInfoTailPtr != nullptr) { - tzZoneInfoTailPtr += tzZoneInfoTailLen; - skipZoneIDPrefix(&tzZoneInfoTailPtr); - if (isValidOlsonID(tzZoneInfoTailPtr)) { - return (gTimeZoneBufferPtr = tzZoneInfoTailPtr); - } + char * tzZoneInfoTailPtr = uprv_strstr(gTimeZoneBuffer, TZZONEINFOTAIL); + + if (tzZoneInfoTailPtr != nullptr + && isValidOlsonID(tzZoneInfoTailPtr + tzZoneInfoTailLen)) + { + return (gTimeZoneBufferPtr = tzZoneInfoTailPtr + tzZoneInfoTailLen); } } else { #if defined(SEARCH_TZFILE) |