Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
2e5048ee
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2e5048ee
编写于
8月 26, 2009
作者:
O
okutsu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6824265: (tz) TimeZone.getTimeZone allows probing local filesystem
Reviewed-by: peytoia
上级
2fb88495
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
45 addition
and
31 deletion
+45
-31
src/share/classes/sun/util/calendar/ZoneInfoFile.java
src/share/classes/sun/util/calendar/ZoneInfoFile.java
+45
-31
未找到文件。
src/share/classes/sun/util/calendar/ZoneInfoFile.java
浏览文件 @
2e5048ee
/*
* Copyright 2000-200
6
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-200
9
Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -472,6 +472,18 @@ public class ZoneInfoFile {
private
static
Map
<
String
,
ZoneInfo
>
zoneInfoObjects
=
null
;
private
static
final
String
ziDir
;
static
{
String
zi
=
(
String
)
AccessController
.
doPrivileged
(
new
sun
.
security
.
action
.
GetPropertyAction
(
"java.home"
))
+
File
.
separator
+
"lib"
+
File
.
separator
+
"zi"
;
try
{
zi
=
new
File
(
zi
).
getCanonicalPath
();
}
catch
(
Exception
e
)
{
}
ziDir
=
zi
;
}
/**
* Converts the given time zone ID to a platform dependent path
* name. For example, "America/Los_Angeles" is converted to
...
...
@@ -576,20 +588,7 @@ public class ZoneInfoFile {
return
null
;
}
int
index
;
for
(
index
=
0
;
index
<
JAVAZI_LABEL
.
length
;
index
++)
{
if
(
buf
[
index
]
!=
JAVAZI_LABEL
[
index
])
{
System
.
err
.
println
(
"ZoneInfo: wrong magic number: "
+
id
);
return
null
;
}
}
if
(
buf
[
index
++]
>
JAVAZI_VERSION
)
{
System
.
err
.
println
(
"ZoneInfo: incompatible version ("
+
buf
[
index
-
1
]
+
"): "
+
id
);
return
null
;
}
int
index
=
0
;
int
filesize
=
buf
.
length
;
int
rawOffset
=
0
;
int
dstSavings
=
0
;
...
...
@@ -600,6 +599,18 @@ public class ZoneInfoFile {
int
[]
simpleTimeZoneParams
=
null
;
try
{
for
(
index
=
0
;
index
<
JAVAZI_LABEL
.
length
;
index
++)
{
if
(
buf
[
index
]
!=
JAVAZI_LABEL
[
index
])
{
System
.
err
.
println
(
"ZoneInfo: wrong magic number: "
+
id
);
return
null
;
}
}
if
(
buf
[
index
++]
>
JAVAZI_VERSION
)
{
System
.
err
.
println
(
"ZoneInfo: incompatible version ("
+
buf
[
index
-
1
]
+
"): "
+
id
);
return
null
;
}
while
(
index
<
filesize
)
{
byte
tag
=
buf
[
index
++];
int
len
=
((
buf
[
index
++]
&
0xFF
)
<<
8
)
+
(
buf
[
index
++]
&
0xFF
);
...
...
@@ -1017,30 +1028,33 @@ public class ZoneInfoFile {
* Reads the specified file under <java.home>/lib/zi into a buffer.
* @return the buffer, or null if any I/O error occurred.
*/
private
static
byte
[]
readZoneInfoFile
(
String
fileName
)
{
private
static
byte
[]
readZoneInfoFile
(
final
String
fileName
)
{
byte
[]
buffer
=
null
;
try
{
String
homeDir
=
AccessController
.
doPrivileged
(
new
sun
.
security
.
action
.
GetPropertyAction
(
"java.home"
));
final
String
fname
=
homeDir
+
File
.
separator
+
"lib"
+
File
.
separator
+
"zi"
+
File
.
separator
+
fileName
;
buffer
=
(
byte
[])
AccessController
.
doPrivileged
(
new
PrivilegedExceptionAction
()
{
public
Object
run
()
throws
IOException
{
File
file
=
new
File
(
fn
ame
);
if
(!
file
.
canRead
())
{
File
file
=
new
File
(
ziDir
,
fileN
ame
);
if
(!
file
.
exists
()
||
!
file
.
isFile
())
{
return
null
;
}
int
filesize
=
(
int
)
file
.
length
();
byte
[]
buf
=
new
byte
[
filesize
];
FileInputStream
fis
=
new
FileInputStream
(
file
);
if
(
fis
.
read
(
buf
)
!=
filesize
)
{
fis
.
close
();
throw
new
IOException
(
"read error on "
+
fname
);
file
=
file
.
getCanonicalFile
();
String
path
=
file
.
getCanonicalPath
();
byte
[]
buf
=
null
;
if
(
path
!=
null
&&
path
.
startsWith
(
ziDir
))
{
int
filesize
=
(
int
)
file
.
length
();
if
(
filesize
>
0
)
{
FileInputStream
fis
=
new
FileInputStream
(
file
);
buf
=
new
byte
[
filesize
];
try
{
if
(
fis
.
read
(
buf
)
!=
filesize
)
{
throw
new
IOException
(
"read error on "
+
fileName
);
}
}
finally
{
fis
.
close
();
}
}
}
fis
.
close
();
return
buf
;
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录