代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/openjdk-11 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From f7e762f525098e19b0f0e9ea8dc2c4a31cae607a Mon Sep 17 00:00:00 2001
From: s00478819 <sunjianye@huawei.com>
Date: Sat, 11 Sep 2021 11:42:19 +0800
Subject: [PATCH 6/8] enhance the TimeZone's path solution on Euler
Summary: <JDK>: enhance the TimeZone's path solution on Euler
LLT: NA
Patch Type: huawei
Bug url: NA
---
.../unix/native/libjava/TimeZone_md.c | 33 ++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/src/java.base/unix/native/libjava/TimeZone_md.c b/src/java.base/unix/native/libjava/TimeZone_md.c
index bb3ba99d5..0780c3601 100644
--- a/src/java.base/unix/native/libjava/TimeZone_md.c
+++ b/src/java.base/unix/native/libjava/TimeZone_md.c
@@ -67,10 +67,12 @@ static char *isFileIdentical(char* buf, size_t size, char *pathname);
static const char *ETC_TIMEZONE_FILE = "/etc/timezone";
static const char *ZONEINFO_DIR = "/usr/share/zoneinfo";
static const char *DEFAULT_ZONEINFO_FILE = "/etc/localtime";
+static const char *DEFAULT_ZONEINFO_FILE_DIRNAME = "/etc";
#else
static const char *SYS_INIT_FILE = "/etc/default/init";
static const char *ZONEINFO_DIR = "/usr/share/lib/zoneinfo";
static const char *DEFAULT_ZONEINFO_FILE = "/usr/share/lib/zoneinfo/localtime";
+static const char *DEFAULT_ZONEINFO_FILE_DIRNAME = "/usr/share/lib/zoneinfo";
#endif /* defined(__linux__) || defined(_ALLBSD_SOURCE) */
static const char popularZones[][4] = {"UTC", "GMT"};
@@ -310,7 +312,36 @@ getPlatformTimeZoneID()
return NULL;
}
linkbuf[len] = '\0';
- tz = getZoneName(linkbuf);
+
+ /* linkbuf may be a relative symlink or has more than one characters, like '.' and '/' ,
+ * which will cause the function call getZoneName return to an abnormal timeZone name.
+ * For example, linkbuf is "../usr/share/zoneinfo//Asia/Shanghai", then the call of
+ * getZoneName(linkbuf) will get "/Asia/Shanghai", not "Asia/Shanghai".
+ * So we covert it to an absolute path by adding the file's (which is define by macro
+ * DEFAULT_ZONEINFO_FILE) dirname and then call glibc's realpath API to canonicalize
+ * the path.
+ */
+ char abslinkbuf[2 * (PATH_MAX + 1)];
+ if (linkbuf[0] != '/') {
+ if (sprintf(abslinkbuf, "%s/%s", DEFAULT_ZONEINFO_FILE_DIRNAME, linkbuf) < 0) {
+ jio_fprintf(stderr, (const char *) "failed to generate absolute path\n");
+ return NULL;
+ }
+ } else {
+ strncpy(abslinkbuf, linkbuf, len + 1);
+ }
+
+ /* canonicalize the path */
+ char resolvedpath[PATH_MAX + 1];
+ resolvedpath[PATH_MAX] = '\0';
+ char *path = realpath(abslinkbuf, resolvedpath);
+ if (path == NULL) {
+ jio_fprintf(stderr, (const char *) "failed to get real path, symlink is %s\n",
+ abslinkbuf);
+ return NULL;
+ }
+
+ tz = getZoneName(resolvedpath);
if (tz != NULL) {
tz = strdup(tz);
return tz;
--
2.22.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。