Skip to content

Commit 69f90b5

Browse files
committed
8259843: initialize dli_fname array before calling dll_address_to_library_name
Reviewed-by: lucy, dholmes
1 parent 52ed2aa commit 69f90b5

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

src/hotspot/os/bsd/os_bsd.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* 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) {
15571557
}
15581558

15591559
char dli_fname[MAXPATHLEN];
1560+
dli_fname[0] = '\0';
15601561
bool ret = dll_address_to_library_name(
15611562
CAST_FROM_FN_PTR(address, os::jvm_path),
15621563
dli_fname, sizeof(dli_fname), NULL);

src/hotspot/os/linux/os_linux.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2637,6 +2637,7 @@ void os::jvm_path(char *buf, jint buflen) {
26372637
}
26382638

26392639
char dli_fname[MAXPATHLEN];
2640+
dli_fname[0] = '\0';
26402641
bool ret = dll_address_to_library_name(
26412642
CAST_FROM_FN_PTR(address, os::jvm_path),
26422643
dli_fname, sizeof(dli_fname), NULL);

src/hotspot/share/prims/nativeLookup.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -434,8 +434,10 @@ void* NativeLookup::dll_load(const methodHandle& method) {
434434
address current_entry = method->native_function();
435435

436436
char dll_name[JVM_MAXPATHLEN];
437+
dll_name[0] = '\0';
437438
int offset;
438-
if (os::dll_address_to_library_name(current_entry, dll_name, sizeof(dll_name), &offset)) {
439+
bool ret = os::dll_address_to_library_name(current_entry, dll_name, sizeof(dll_name), &offset);
440+
if (ret && dll_name[0] != '\0') {
439441
char ebuf[32];
440442
return os::dll_load(dll_name, ebuf, sizeof(ebuf));
441443
}

src/hotspot/share/runtime/frame.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* 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) {
540540
int offset;
541541
bool found;
542542

543+
if (buf == NULL || buflen < 1) return;
543544
// libname
545+
buf[0] = '\0';
544546
found = os::dll_address_to_library_name(pc, buf, buflen, &offset);
545-
if (found) {
547+
if (found && buf[0] != '\0') {
546548
// skip directory names
547549
const char *p1, *p2;
548550
p1 = buf;

0 commit comments

Comments
 (0)