8267130: Memory Overflow in Disassembler::load_library
Co-authored-by: Wang Huang <whuang@openjdk.org> Co-authored-by: Miao Zhuojun <mouzhuojun@huawei.com> Reviewed-by: neliasso, mli
This commit is contained in:
parent
9d305b9c06
commit
083416d36c
@ -804,16 +804,24 @@ bool Disassembler::load_library(outputStream* st) {
|
||||
// 4. hsdis-<arch>.so (using LD_LIBRARY_PATH)
|
||||
if (jvm_offset >= 0) {
|
||||
// 1. <home>/lib/<vm>/libhsdis-<arch>.so
|
||||
strcpy(&buf[jvm_offset], hsdis_library_name);
|
||||
strcat(&buf[jvm_offset], os::dll_file_extension());
|
||||
if (Verbose) st->print_cr("Trying to load: %s", buf);
|
||||
_library = os::dll_load(buf, ebuf, sizeof ebuf);
|
||||
if (_library == NULL && lib_offset >= 0) {
|
||||
// 2. <home>/lib/<vm>/hsdis-<arch>.so
|
||||
strcpy(&buf[lib_offset], hsdis_library_name);
|
||||
strcat(&buf[lib_offset], os::dll_file_extension());
|
||||
if (jvm_offset + strlen(hsdis_library_name) + strlen(os::dll_file_extension()) < JVM_MAXPATHLEN) {
|
||||
strcpy(&buf[jvm_offset], hsdis_library_name);
|
||||
strcat(&buf[jvm_offset], os::dll_file_extension());
|
||||
if (Verbose) st->print_cr("Trying to load: %s", buf);
|
||||
_library = os::dll_load(buf, ebuf, sizeof ebuf);
|
||||
} else {
|
||||
if (Verbose) st->print_cr("Try to load hsdis library failed: the length of path is beyond the OS limit");
|
||||
}
|
||||
if (_library == NULL && lib_offset >= 0) {
|
||||
// 2. <home>/lib/<vm>/hsdis-<arch>.so
|
||||
if (lib_offset + strlen(hsdis_library_name) + strlen(os::dll_file_extension()) < JVM_MAXPATHLEN) {
|
||||
strcpy(&buf[lib_offset], hsdis_library_name);
|
||||
strcat(&buf[lib_offset], os::dll_file_extension());
|
||||
if (Verbose) st->print_cr("Trying to load: %s", buf);
|
||||
_library = os::dll_load(buf, ebuf, sizeof ebuf);
|
||||
} else {
|
||||
if (Verbose) st->print_cr("Try to load hsdis library failed: the length of path is beyond the OS limit");
|
||||
}
|
||||
}
|
||||
if (_library == NULL && lib_offset > 0) {
|
||||
// 3. <home>/lib/hsdis-<arch>.so
|
||||
@ -821,10 +829,14 @@ bool Disassembler::load_library(outputStream* st) {
|
||||
const char* p = strrchr(buf, *os::file_separator());
|
||||
if (p != NULL) {
|
||||
lib_offset = p - buf + 1;
|
||||
strcpy(&buf[lib_offset], hsdis_library_name);
|
||||
strcat(&buf[lib_offset], os::dll_file_extension());
|
||||
if (Verbose) st->print_cr("Trying to load: %s", buf);
|
||||
_library = os::dll_load(buf, ebuf, sizeof ebuf);
|
||||
if (lib_offset + strlen(hsdis_library_name) + strlen(os::dll_file_extension()) < JVM_MAXPATHLEN) {
|
||||
strcpy(&buf[lib_offset], hsdis_library_name);
|
||||
strcat(&buf[lib_offset], os::dll_file_extension());
|
||||
if (Verbose) st->print_cr("Trying to load: %s", buf);
|
||||
_library = os::dll_load(buf, ebuf, sizeof ebuf);
|
||||
} else {
|
||||
if (Verbose) st->print_cr("Try to load hsdis library failed: the length of path is beyond the OS limit");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user