• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git a/source/common/putil.cpp b/source/common/putil.cpp
2index ab904af2..42e8be11 100644
3--- a/source/common/putil.cpp
4+++ b/source/common/putil.cpp
5@@ -722,7 +722,7 @@ extern U_IMPORT char *U_TZNAME[];
6 #include <dirent.h>  /* Needed to search through system timezone files */
7 #endif
8 static char gTimeZoneBuffer[PATH_MAX];
9-static const char *gTimeZoneBufferPtr = nullptr;
10+static char *gTimeZoneBufferPtr = nullptr;
11 #endif
12
13 #if !U_PLATFORM_USES_ONLY_WIN32_API
14@@ -1171,16 +1171,15 @@ uprv_tzname(int n)
15         because the tzfile contents is underspecified.
16         This isn't guaranteed to work because it may not be a symlink.
17         */
18-        char *ret = realpath(TZDEFAULT, gTimeZoneBuffer);
19-        if (ret != nullptr && uprv_strcmp(TZDEFAULT, gTimeZoneBuffer) != 0) {
20+        int32_t ret = (int32_t)readlink(TZDEFAULT, gTimeZoneBuffer, sizeof(gTimeZoneBuffer)-1);
21+        if (0 < ret) {
22             int32_t tzZoneInfoTailLen = uprv_strlen(TZZONEINFOTAIL);
23-            const char *tzZoneInfoTailPtr = uprv_strstr(gTimeZoneBuffer, TZZONEINFOTAIL);
24-            if (tzZoneInfoTailPtr != nullptr) {
25-                tzZoneInfoTailPtr += tzZoneInfoTailLen;
26-                skipZoneIDPrefix(&tzZoneInfoTailPtr);
27-                if (isValidOlsonID(tzZoneInfoTailPtr)) {
28-                    return (gTimeZoneBufferPtr = tzZoneInfoTailPtr);
29-                }
30+            char *  tzZoneInfoTailPtr = uprv_strstr(gTimeZoneBuffer, TZZONEINFOTAIL);
31+
32+            if (tzZoneInfoTailPtr != nullptr
33+                && isValidOlsonID(tzZoneInfoTailPtr + tzZoneInfoTailLen))
34+            {
35+                return (gTimeZoneBufferPtr = tzZoneInfoTailPtr + tzZoneInfoTailLen);
36             }
37         } else {
38 #if defined(SEARCH_TZFILE)
39diff --git a/source/common/uposixdefs.h b/source/common/uposixdefs.h
40index 7c008fdd..3770a335 100644
41--- a/source/common/uposixdefs.h
42+++ b/source/common/uposixdefs.h
43@@ -48,7 +48,7 @@
44 #endif
45
46 /*
47- * Make sure things like realpath and such functions work.
48+ * Make sure things like readlink and such functions work.
49  * Poorly upgraded Solaris machines can't have this defined.
50  * Cleanly installed Solaris can use this #define.
51  *
52diff --git a/source/test/depstest/dependencies.txt b/source/test/depstest/dependencies.txt
53index d95e4de3..28a2dc70 100644
54--- a/source/test/depstest/dependencies.txt
55+++ b/source/test/depstest/dependencies.txt
56@@ -22,7 +22,7 @@ system_symbols:
57     exp_and_tanhf
58     stdlib_qsort
59     system_locale
60-    stdio_input stdio_output file_io realpath_function dir_io mmap_functions dlfcn
61+    stdio_input stdio_output file_io readlink_function dir_io mmap_functions dlfcn
62     # C++
63     cplusplus iostream
64     std_mutex
65@@ -110,8 +110,8 @@ group: file_io
66     # Additional symbols in an optimized build.
67     __xstat
68
69-group: realpath_function
70-    realpath  # putil.cpp uprv_tzname() calls this in a hack to get the time zone name
71+group: readlink_function
72+    readlink  # putil.cpp uprv_tzname() calls this in a hack to get the time zone name
73
74 group: dir_io
75     opendir closedir readdir  # for a hack to get the time zone name
76@@ -869,7 +869,7 @@ group: platform
77     PIC system_misc system_debug malloc_functions ubsan
78     c_strings c_string_formatting
79     floating_point system_locale
80-    stdio_input realpath_function dir_io
81+    stdio_input readlink_function dir_io
82     dlfcn  # Move related code into icuplug.c?
83     cplusplus
84     std_mutex
85