8259843: initialize dli_fname array before calling dll_address_to_library_name

Reviewed-by: lucy, dholmes
This commit is contained in:
Matthias Baesken 2021-01-20 15:08:02 +00:00
parent 52ed2aab9b
commit 69f90b5fd4
4 changed files with 11 additions and 5 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, 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
@ -1557,6 +1557,7 @@ void os::jvm_path(char *buf, jint buflen) {
}
char dli_fname[MAXPATHLEN];
dli_fname[0] = '\0';
bool ret = dll_address_to_library_name(
CAST_FROM_FN_PTR(address, os::jvm_path),
dli_fname, sizeof(dli_fname), NULL);

View File

@ -2637,6 +2637,7 @@ void os::jvm_path(char *buf, jint buflen) {
}
char dli_fname[MAXPATHLEN];
dli_fname[0] = '\0';
bool ret = dll_address_to_library_name(
CAST_FROM_FN_PTR(address, os::jvm_path),
dli_fname, sizeof(dli_fname), NULL);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, 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
@ -434,8 +434,10 @@ void* NativeLookup::dll_load(const methodHandle& method) {
address current_entry = method->native_function();
char dll_name[JVM_MAXPATHLEN];
dll_name[0] = '\0';
int offset;
if (os::dll_address_to_library_name(current_entry, dll_name, sizeof(dll_name), &offset)) {
bool ret = os::dll_address_to_library_name(current_entry, dll_name, sizeof(dll_name), &offset);
if (ret && dll_name[0] != '\0') {
char ebuf[32];
return os::dll_load(dll_name, ebuf, sizeof(ebuf));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, 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
@ -540,9 +540,11 @@ void frame::print_C_frame(outputStream* st, char* buf, int buflen, address pc) {
int offset;
bool found;
if (buf == NULL || buflen < 1) return;
// libname
buf[0] = '\0';
found = os::dll_address_to_library_name(pc, buf, buflen, &offset);
if (found) {
if (found && buf[0] != '\0') {
// skip directory names
const char *p1, *p2;
p1 = buf;