Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
37862f19
D
dragonwell8_hotspot
项目概览
openanolis
/
dragonwell8_hotspot
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_hotspot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
37862f19
编写于
4月 03, 2020
作者:
A
aph
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8076475: Misuses of strncpy/strncat
Summary: Various small fixes around strncpy and strncat Reviewed-by: andrew
上级
9f54daa4
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
52 addition
and
44 deletion
+52
-44
agent/src/os/bsd/libproc_impl.c
agent/src/os/bsd/libproc_impl.c
+6
-1
agent/src/os/linux/libproc_impl.c
agent/src/os/linux/libproc_impl.c
+6
-1
src/os/bsd/dtrace/libjvm_db.c
src/os/bsd/dtrace/libjvm_db.c
+10
-9
src/os/bsd/vm/decoder_machO.cpp
src/os/bsd/vm/decoder_machO.cpp
+1
-0
src/os/solaris/dtrace/libjvm_db.c
src/os/solaris/dtrace/libjvm_db.c
+10
-9
src/share/tools/hsdis/hsdis.c
src/share/tools/hsdis/hsdis.c
+1
-0
src/share/vm/compiler/compileBroker.hpp
src/share/vm/compiler/compileBroker.hpp
+2
-1
src/share/vm/compiler/disassembler.cpp
src/share/vm/compiler/disassembler.cpp
+1
-0
src/share/vm/runtime/arguments.cpp
src/share/vm/runtime/arguments.cpp
+6
-11
src/share/vm/utilities/ostream.cpp
src/share/vm/utilities/ostream.cpp
+8
-4
src/share/vm/utilities/vmError.cpp
src/share/vm/utilities/vmError.cpp
+1
-8
未找到文件。
agent/src/os/bsd/libproc_impl.c
浏览文件 @
37862f19
...
...
@@ -215,7 +215,12 @@ lib_info* add_lib_info_fd(struct ps_prochandle* ph, const char* libname, int fd,
return
NULL
;
}
strncpy
(
newlib
->
name
,
libname
,
sizeof
(
newlib
->
name
));
if
(
strlen
(
libname
)
>=
sizeof
(
newlib
->
name
))
{
print_debug
(
"libname %s too long
\n
"
,
libname
);
return
NULL
;
}
strcpy
(
newlib
->
name
,
libname
);
newlib
->
base
=
base
;
if
(
fd
==
-
1
)
{
...
...
agent/src/os/linux/libproc_impl.c
浏览文件 @
37862f19
...
...
@@ -159,7 +159,12 @@ lib_info* add_lib_info_fd(struct ps_prochandle* ph, const char* libname, int fd,
return
NULL
;
}
strncpy
(
newlib
->
name
,
libname
,
sizeof
(
newlib
->
name
));
if
(
strlen
(
libname
)
>=
sizeof
(
newlib
->
name
))
{
print_debug
(
"libname %s too long
\n
"
,
libname
);
return
NULL
;
}
strcpy
(
newlib
->
name
,
libname
);
newlib
->
base
=
base
;
if
(
fd
==
-
1
)
{
...
...
src/os/bsd/dtrace/libjvm_db.c
浏览文件 @
37862f19
...
...
@@ -543,13 +543,14 @@ name_for_methodPtr(jvm_agent_t* J, uint64_t methodPtr, char * result, size_t siz
CHECK_FAIL
(
err
);
result
[
0
]
=
'\0'
;
strncat
(
result
,
klassString
,
size
);
size
-=
strlen
(
klassString
);
strncat
(
result
,
"."
,
size
);
size
-=
1
;
strncat
(
result
,
nameString
,
size
);
size
-=
strlen
(
nameString
);
strncat
(
result
,
signatureString
,
size
);
if
(
snprintf
(
result
,
size
,
"%s.%s%s"
,
klassString
,
nameString
,
signatureString
)
>=
size
)
{
// truncation
goto
fail
;
}
if
(
nameString
!=
NULL
)
free
(
nameString
);
if
(
klassString
!=
NULL
)
free
(
klassString
);
...
...
@@ -1056,9 +1057,9 @@ name_for_nmethod(jvm_agent_t* J,
CHECK_FAIL
(
err
);
}
if
(
deoptimized
)
{
strncat
(
result
+
1
,
" [deoptimized frame]; "
,
size
-
1
);
strncat
(
result
,
" [deoptimized frame]; "
,
size
-
strlen
(
result
)
-
1
);
}
else
{
strncat
(
result
+
1
,
" [compiled] "
,
size
-
1
);
strncat
(
result
,
" [compiled] "
,
size
-
strlen
(
result
)
-
1
);
}
if
(
debug
)
fprintf
(
stderr
,
"name_for_nmethod: END: method name: %s, vf_cnt: %d
\n\n
"
,
...
...
src/os/bsd/vm/decoder_machO.cpp
浏览文件 @
37862f19
...
...
@@ -97,6 +97,7 @@ bool MachODecoder::decode(address addr, char *buf,
char
*
symname
=
mach_find_in_stringtable
((
char
*
)
((
uintptr_t
)
mach_base
+
stroff
),
strsize
,
found_strx
);
if
(
symname
)
{
strncpy
(
buf
,
symname
,
buflen
);
buf
[
buflen
-
1
]
=
'\0'
;
return
true
;
}
DEBUG_ONLY
(
tty
->
print_cr
(
"no string or null string found."
));
...
...
src/os/solaris/dtrace/libjvm_db.c
浏览文件 @
37862f19
...
...
@@ -543,13 +543,14 @@ name_for_methodPtr(jvm_agent_t* J, uint64_t methodPtr, char * result, size_t siz
CHECK_FAIL
(
err
);
result
[
0
]
=
'\0'
;
strncat
(
result
,
klassString
,
size
);
size
-=
strlen
(
klassString
);
strncat
(
result
,
"."
,
size
);
size
-=
1
;
strncat
(
result
,
nameString
,
size
);
size
-=
strlen
(
nameString
);
strncat
(
result
,
signatureString
,
size
);
if
(
snprintf
(
result
,
size
,
"%s.%s%s"
,
klassString
,
nameString
,
signatureString
)
>=
size
)
{
// truncation
goto
fail
;
}
if
(
nameString
!=
NULL
)
free
(
nameString
);
if
(
klassString
!=
NULL
)
free
(
klassString
);
...
...
@@ -1056,9 +1057,9 @@ name_for_nmethod(jvm_agent_t* J,
CHECK_FAIL
(
err
);
}
if
(
deoptimized
)
{
strncat
(
result
+
1
,
" [deoptimized frame]; "
,
size
-
1
);
strncat
(
result
,
" [deoptimized frame]; "
,
size
-
strlen
(
result
)
-
1
);
}
else
{
strncat
(
result
+
1
,
" [compiled] "
,
size
-
1
);
strncat
(
result
,
" [compiled] "
,
size
-
strlen
(
result
)
-
1
);
}
if
(
debug
)
fprintf
(
stderr
,
"name_for_nmethod: END: method name: %s, vf_cnt: %d
\n\n
"
,
...
...
src/share/tools/hsdis/hsdis.c
浏览文件 @
37862f19
...
...
@@ -438,6 +438,7 @@ static void parse_caller_options(struct hsdis_app_data* app_data, const char* ca
}
p
=
q
;
}
*
iop
=
'\0'
;
}
static
void
print_help
(
struct
hsdis_app_data
*
app_data
,
...
...
src/share/vm/compiler/compileBroker.hpp
浏览文件 @
37862f19
...
...
@@ -173,7 +173,8 @@ class CompilerCounters : public CHeapObj<mtCompiler> {
// these methods should be called in a thread safe context
void
set_current_method
(
const
char
*
method
)
{
strncpy
(
_current_method
,
method
,
(
size_t
)
cmname_buffer_length
);
strncpy
(
_current_method
,
method
,
(
size_t
)
cmname_buffer_length
-
1
);
_current_method
[
cmname_buffer_length
-
1
]
=
'\0'
;
if
(
UsePerfData
)
_perf_current_method
->
set_value
(
method
);
}
...
...
src/share/vm/compiler/disassembler.cpp
浏览文件 @
37862f19
...
...
@@ -295,6 +295,7 @@ address decode_env::handle_event(const char* event, address arg) {
strlen
((
const
char
*
)
arg
)
>
sizeof
(
buffer
)
-
1
)
{
// Only print this when the mach changes
strncpy
(
buffer
,
(
const
char
*
)
arg
,
sizeof
(
buffer
)
-
1
);
buffer
[
sizeof
(
buffer
)
-
1
]
=
'\0'
;
output
()
->
print_cr
(
"[Disassembling for mach='%s']"
,
arg
);
}
}
else
if
(
match
(
event
,
"format bytes-per-line"
))
{
...
...
src/share/vm/runtime/arguments.cpp
浏览文件 @
37862f19
...
...
@@ -3476,8 +3476,7 @@ void Arguments::fix_appclasspath() {
src
++
;
}
char
*
copy
=
AllocateHeap
(
strlen
(
src
)
+
1
,
mtInternal
);
strncpy
(
copy
,
src
,
strlen
(
src
)
+
1
);
char
*
copy
=
os
::
strdup
(
src
,
mtInternal
);
// trim all trailing empty paths
for
(
char
*
tail
=
copy
+
strlen
(
copy
)
-
1
;
tail
>=
copy
&&
*
tail
==
separator
;
tail
--
)
{
...
...
@@ -3856,18 +3855,14 @@ static char* get_shared_archive_path() {
if
(
end
!=
NULL
)
*
end
=
'\0'
;
size_t
jvm_path_len
=
strlen
(
jvm_path
);
size_t
file_sep_len
=
strlen
(
os
::
file_separator
());
shared_archive_path
=
NEW_C_HEAP_ARRAY
(
char
,
jvm_path_len
+
file_sep_len
+
20
,
mtInternal
);
const
size_t
len
=
jvm_path_len
+
file_sep_len
+
20
;
shared_archive_path
=
NEW_C_HEAP_ARRAY
(
char
,
len
,
mtInternal
);
if
(
shared_archive_path
!=
NULL
)
{
strncpy
(
shared_archive_path
,
jvm_path
,
jvm_path_len
+
1
);
strncat
(
shared_archive_path
,
os
::
file_separator
(),
file_sep_len
);
strncat
(
shared_archive_path
,
"classes.jsa"
,
11
);
jio_snprintf
(
shared_archive_path
,
len
,
"%s%sclasses.jsa"
,
jvm_path
,
os
::
file_separator
());
}
}
else
{
shared_archive_path
=
NEW_C_HEAP_ARRAY
(
char
,
strlen
(
SharedArchiveFile
)
+
1
,
mtInternal
);
if
(
shared_archive_path
!=
NULL
)
{
strncpy
(
shared_archive_path
,
SharedArchiveFile
,
strlen
(
SharedArchiveFile
)
+
1
);
}
shared_archive_path
=
os
::
strdup
(
SharedArchiveFile
,
mtInternal
);
}
return
shared_archive_path
;
}
...
...
src/share/vm/utilities/ostream.cpp
浏览文件 @
37862f19
...
...
@@ -344,15 +344,19 @@ void stringStream::write(const char* s, size_t len) {
assert
(
rm
==
NULL
||
Thread
::
current
()
->
current_resource_mark
()
==
rm
,
"stringStream is re-allocated with a different ResourceMark"
);
buffer
=
NEW_RESOURCE_ARRAY
(
char
,
end
);
strncpy
(
buffer
,
oldbuf
,
buffer_pos
);
if
(
buffer_pos
>
0
)
{
memcpy
(
buffer
,
oldbuf
,
buffer_pos
);
}
buffer_length
=
end
;
}
}
// invariant: buffer is always null-terminated
guarantee
(
buffer_pos
+
write_len
+
1
<=
buffer_length
,
"stringStream oob"
);
if
(
write_len
>
0
)
{
buffer
[
buffer_pos
+
write_len
]
=
0
;
strn
cpy
(
buffer
+
buffer_pos
,
s
,
write_len
);
mem
cpy
(
buffer
+
buffer_pos
,
s
,
write_len
);
buffer_pos
+=
write_len
;
}
// Note that the following does not depend on write_len.
// This means that position and count get updated
...
...
src/share/vm/utilities/vmError.cpp
浏览文件 @
37862f19
...
...
@@ -455,14 +455,7 @@ void VMError::report(outputStream* st) {
#else
const
char
*
file
=
_filename
;
#endif
size_t
len
=
strlen
(
file
);
size_t
buflen
=
sizeof
(
buf
);
strncpy
(
buf
,
file
,
buflen
);
if
(
len
+
10
<
buflen
)
{
sprintf
(
buf
+
len
,
":%d"
,
_lineno
);
}
st
->
print
(
" (%s)"
,
buf
);
st
->
print
(
" (%s:%d)"
,
file
,
_lineno
);
}
else
{
st
->
print
(
" (0x%x)"
,
_id
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录