Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
2cdaff4d
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看板
提交
2cdaff4d
编写于
6月 14, 2017
作者:
W
weijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8181841: A TSA server returns timestamp with precision higher than milliseconds
Reviewed-by: vinnie
上级
59c72f31
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
39 addition
and
28 deletion
+39
-28
src/share/classes/sun/security/util/DerInputBuffer.java
src/share/classes/sun/security/util/DerInputBuffer.java
+23
-25
test/sun/security/util/DerInputBuffer/TimeParsing.java
test/sun/security/util/DerInputBuffer/TimeParsing.java
+16
-3
未找到文件。
src/share/classes/sun/security/util/DerInputBuffer.java
浏览文件 @
2cdaff4d
...
...
@@ -27,7 +27,6 @@ package sun.security.util;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.math.BigInteger
;
import
java.util.Date
;
import
sun.util.calendar.CalendarDate
;
...
...
@@ -275,7 +274,7 @@ class DerInputBuffer extends ByteArrayInputStream implements Cloneable {
if
(
len
>
available
())
throw
new
IOException
(
"short read of DER Generalized Time"
);
if
(
len
<
13
||
len
>
23
)
if
(
len
<
13
)
throw
new
IOException
(
"DER Generalized Time length error"
);
return
getTime
(
len
,
true
);
...
...
@@ -350,7 +349,7 @@ class DerInputBuffer extends ByteArrayInputStream implements Cloneable {
*/
millis
=
0
;
if
(
len
>
2
&&
len
<
12
)
{
if
(
len
>
2
)
{
second
=
10
*
Character
.
digit
((
char
)
buf
[
pos
++],
10
);
second
+=
Character
.
digit
((
char
)
buf
[
pos
++],
10
);
len
-=
2
;
...
...
@@ -358,31 +357,30 @@ class DerInputBuffer extends ByteArrayInputStream implements Cloneable {
if
(
buf
[
pos
]
==
'.'
||
buf
[
pos
]
==
','
)
{
len
--;
pos
++;
// handle upto milisecond precision only
int
precision
=
0
;
int
peek
=
pos
;
while
(
buf
[
peek
]
!=
'Z'
&&
buf
[
peek
]
!=
'+'
&&
buf
[
peek
]
!=
'-'
)
{
peek
++;
while
(
buf
[
pos
]
!=
'Z'
&&
buf
[
pos
]
!=
'+'
&&
buf
[
pos
]
!=
'-'
)
{
// Validate all digits in the fractional part but
// store millisecond precision only
int
thisDigit
=
Character
.
digit
((
char
)
buf
[
pos
],
10
);
precision
++;
pos
++;
switch
(
precision
)
{
case
1
:
millis
+=
100
*
thisDigit
;
break
;
case
2
:
millis
+=
10
*
thisDigit
;
break
;
case
3
:
millis
+=
thisDigit
;
break
;
}
}
switch
(
precision
)
{
case
3
:
millis
+=
100
*
Character
.
digit
((
char
)
buf
[
pos
++],
10
);
millis
+=
10
*
Character
.
digit
((
char
)
buf
[
pos
++],
10
);
millis
+=
Character
.
digit
((
char
)
buf
[
pos
++],
10
);
break
;
case
2
:
millis
+=
100
*
Character
.
digit
((
char
)
buf
[
pos
++],
10
);
millis
+=
10
*
Character
.
digit
((
char
)
buf
[
pos
++],
10
);
break
;
case
1
:
millis
+=
100
*
Character
.
digit
((
char
)
buf
[
pos
++],
10
);
break
;
default
:
throw
new
IOException
(
"Parse "
+
type
+
" time, unsupported precision for seconds value"
);
if
(
precision
==
0
)
{
throw
new
IOException
(
"Parse "
+
type
+
" time, empty fractional part"
);
}
len
-=
precision
;
}
...
...
test/sun/security/util/DerInputBuffer/TimeParsing.java
浏览文件 @
2cdaff4d
/*
* Copyright (c) 2002, 20
03
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 20
17
, Oracle and/or its affiliates. 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
...
...
@@ -23,7 +23,7 @@
/*
* @test
* @bug 4558835 4915146
* @bug 4558835 4915146
8181841
* @summary Verify timezone offset and fractional seconds are correctly parsed
*/
...
...
@@ -76,6 +76,10 @@ public class TimeParsing {
private
final
static
byte
[]
GEN_FRACT3_ZULU
=
{
0x18
,
0x13
,
0x32
,
0x30
,
0x30
,
0x31
,
0x30
,
0x38
,
0x31
,
0x30
,
0x31
,
0x37
,
0x34
,
0x33
,
0x35
,
0x31
,
0x2e
,
0x37
,
0x36
,
0x35
,
0x5a
};
// 20010810174351.7654Z
private
final
static
byte
[]
GEN_FRACT4_ZULU
=
{
0x18
,
0x14
,
0x32
,
0x30
,
0x30
,
0x31
,
0x30
,
0x38
,
0x31
,
0x30
,
0x31
,
0x37
,
0x34
,
0x33
,
0x35
,
0x31
,
0x2e
,
0x37
,
0x36
,
0x35
,
0x34
,
0x5a
};
// 20010810184351.7+0100
private
final
static
byte
[]
GEN_FRACT1_PLUS1
=
{
0x18
,
0x15
,
0x32
,
0x30
,
0x30
,
0x31
,
0x30
,
0x38
,
0x31
,
0x30
,
0x31
,
0x38
,
0x34
,
0x33
,
0x35
,
0x31
,
0x2e
,
0x37
,
0x2b
,
0x30
,
0x31
,
0x30
,
0x30
};
...
...
@@ -88,10 +92,17 @@ public class TimeParsing {
private
final
static
byte
[]
GEN_FRACT3_PLUS1
=
{
0x18
,
0x17
,
0x32
,
0x30
,
0x30
,
0x31
,
0x30
,
0x38
,
0x31
,
0x30
,
0x31
,
0x38
,
0x34
,
0x33
,
0x35
,
0x31
,
0x2e
,
0x37
,
0x36
,
0x35
,
0x2b
,
0x30
,
0x31
,
0x30
,
0x30
};
// 20010810184351.7654+0100
private
final
static
byte
[]
GEN_FRACT4_PLUS1
=
{
0x18
,
0x18
,
0x32
,
0x30
,
0x30
,
0x31
,
0x30
,
0x38
,
0x31
,
0x30
,
0x31
,
0x38
,
0x34
,
0x33
,
0x35
,
0x31
,
0x2e
,
0x37
,
0x36
,
0x35
,
0x34
,
0x2b
,
0x30
,
0x31
,
0x30
,
0x30
};
// 20010810184351,765+0100
private
final
static
byte
[]
GEN_FRACT3_COMMA_PLUS1
=
{
0x18
,
0x17
,
0x32
,
0x30
,
0x30
,
0x31
,
0x30
,
0x38
,
0x31
,
0x30
,
0x31
,
0x38
,
0x34
,
0x33
,
0x35
,
0x31
,
0x2c
,
0x37
,
0x36
,
0x35
,
0x2b
,
0x30
,
0x31
,
0x30
,
0x30
};
// 20010810184351,7654+0100
private
final
static
byte
[]
GEN_FRACT4_COMMA_PLUS1
=
{
0x18
,
0x18
,
0x32
,
0x30
,
0x30
,
0x31
,
0x30
,
0x38
,
0x31
,
0x30
,
0x31
,
0x38
,
0x34
,
0x33
,
0x35
,
0x31
,
0x2c
,
0x37
,
0x36
,
0x35
,
0x34
,
0x2b
,
0x30
,
0x31
,
0x30
,
0x30
};
private
static
Date
decodeUTC
(
byte
[]
b
)
throws
IOException
{
DerInputStream
derin
=
new
DerInputStream
(
b
);
...
...
@@ -145,6 +156,8 @@ public class TimeParsing {
checkGeneralized
(
d3
,
GEN_FRACT3_ZULU
,
"fractional seconds (Zulu)"
);
checkGeneralized
(
d3
,
GEN_FRACT3_PLUS1
,
"fractional seconds (+0100)"
);
checkGeneralized
(
d3
,
GEN_FRACT3_COMMA_PLUS1
,
"fractional seconds (+0100)"
);
checkGeneralized
(
d3
,
GEN_FRACT4_ZULU
,
"fractional seconds (Zulu)"
);
checkGeneralized
(
d3
,
GEN_FRACT4_PLUS1
,
"fractional seconds (+0100)"
);
checkGeneralized
(
d3
,
GEN_FRACT4_COMMA_PLUS1
,
"fractional seconds (+0100)"
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录