Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/hotspot/cpu/zero/frame_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ void frame::zero_print_on_error(int frame_index,
os::snprintf_checked(fieldbuf, buflen, "word[%d]", offset);
os::snprintf_checked(valuebuf, buflen, PTR_FORMAT, *addr);
zeroframe()->identify_word(frame_index, offset, fieldbuf, valuebuf, buflen);
fieldbuf[buflen - 1] = '\0';
valuebuf[buflen - 1] = '\0';

// Print the result
st->print_cr(" " PTR_FORMAT ": %-21s = %s", p2i(addr), fieldbuf, valuebuf);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/aix/os_aix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ static void* dll_load_library(const char *filename, int *eno, char *ebuf, int eb
error_report = "dlerror returned no error description";
}
if (ebuf != nullptr && ebuflen > 0) {
os::snprintf_checked(ebuf, ebuflen - 1, "%s, LIBPATH=%s, LD_LIBRARY_PATH=%s : %s",
os::snprintf_checked(ebuf, ebuflen, "%s, LIBPATH=%s, LD_LIBRARY_PATH=%s : %s",
filename, ::getenv("LIBPATH"), ::getenv("LD_LIBRARY_PATH"), error_report);
}
Events::log_dll_message(nullptr, "Loading shared library %s failed, %s", filename, error_report);
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/os/aix/porting_aix.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012, 2024 SAP SE. All rights reserved.
* Copyright (c) 2025, 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
Expand Down Expand Up @@ -1154,7 +1155,7 @@ bool os::pd_dll_unload(void* libhandle, char* ebuf, int ebuflen) {
error_report = "dlerror returned no error description";
}
if (ebuf != nullptr && ebuflen > 0) {
os::snprintf_checked(ebuf, ebuflen - 1, "%s", error_report);
os::snprintf_checked(ebuf, ebuflen, "%s", error_report);
}
assert(false, "os::pd_dll_unload() ::dlclose() failed");
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/bsd/os_bsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2495,7 +2495,7 @@ bool os::pd_dll_unload(void* libhandle, char* ebuf, int ebuflen) {
error_report = "dlerror returned no error description";
}
if (ebuf != nullptr && ebuflen > 0) {
os::snprintf_checked(ebuf, ebuflen - 1, "%s", error_report);
os::snprintf_checked(ebuf, ebuflen, "%s", error_report);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5443,7 +5443,7 @@ bool os::pd_dll_unload(void* libhandle, char* ebuf, int ebuflen) {
error_report = "dlerror returned no error description";
}
if (ebuf != nullptr && ebuflen > 0) {
os::snprintf_checked(ebuf, ebuflen - 1, "%s", error_report);
os::snprintf_checked(ebuf, ebuflen, "%s", error_report);
}
}

Expand Down
6 changes: 0 additions & 6 deletions src/hotspot/os/linux/os_perf_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,9 @@ bool SystemProcessInterface::SystemProcesses::ProcessIterator::is_valid_entry(st

if (atoi(entry->d_name) != 0) {
jio_snprintf(buffer, PATH_MAX, "/proc/%s", entry->d_name);
buffer[PATH_MAX - 1] = '\0';

if (is_dir(buffer)) {
jio_snprintf(buffer, PATH_MAX, "/proc/%s/stat", entry->d_name);
buffer[PATH_MAX - 1] = '\0';
if (fsize(buffer, size) != OS_ERR) {
return true;
}
Expand All @@ -724,7 +722,6 @@ void SystemProcessInterface::SystemProcesses::ProcessIterator::get_exe_name() {
char buffer[PATH_MAX];

jio_snprintf(buffer, PATH_MAX, "/proc/%s/stat", _entry->d_name);
buffer[PATH_MAX - 1] = '\0';
if ((fp = os::fopen(buffer, "r")) != nullptr) {
if (fgets(buffer, PATH_MAX, fp) != nullptr) {
char* start, *end;
Expand Down Expand Up @@ -752,7 +749,6 @@ char* SystemProcessInterface::SystemProcesses::ProcessIterator::get_cmdline() {
char* cmdline = nullptr;

jio_snprintf(buffer, PATH_MAX, "/proc/%s/cmdline", _entry->d_name);
buffer[PATH_MAX - 1] = '\0';
if ((fp = os::fopen(buffer, "r")) != nullptr) {
size_t size = 0;
char dummy;
Expand Down Expand Up @@ -787,7 +783,6 @@ char* SystemProcessInterface::SystemProcesses::ProcessIterator::get_exe_path() {
char buffer[PATH_MAX];

jio_snprintf(buffer, PATH_MAX, "/proc/%s/exe", _entry->d_name);
buffer[PATH_MAX - 1] = '\0';
return os::realpath(buffer, _exePath, PATH_MAX);
}

Expand Down Expand Up @@ -1001,7 +996,6 @@ int64_t NetworkPerformanceInterface::NetworkPerformance::read_counter(const char
return -1;
}

buf[num_bytes] = '\0';
int64_t value = strtoll(buf, nullptr, 10);

return value;
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/os/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1827,12 +1827,12 @@ void * os::dll_load(const char *name, char *ebuf, int ebuflen) {
}

if (lib_arch_str != nullptr) {
os::snprintf_checked(ebuf, ebuflen - 1,
os::snprintf_checked(ebuf, ebuflen,
"Can't load %s-bit .dll on a %s-bit platform",
lib_arch_str, running_arch_str);
} else {
// don't know what architecture this dll was build for
os::snprintf_checked(ebuf, ebuflen - 1,
os::snprintf_checked(ebuf, ebuflen,
"Can't load this .dll (machine code=0x%x) on a %s-bit platform",
lib_arch, running_arch_str);
}
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/cds/filemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ template <int N> static void get_header_version(char (&header_version) [N]) {

// Append the hash code as eight hex digits.
os::snprintf_checked(&header_version[JVM_IDENT_MAX-9], 9, "%08x", hash);
header_version[JVM_IDENT_MAX-1] = 0; // Null terminate.
}

assert(header_version[JVM_IDENT_MAX-1] == 0, "must be");
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/runtime/reflection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ char* Reflection::verify_class_access_msg(const Klass* current_class,
size_t len = 100 + strlen(current_class_name) + 2*strlen(module_from_name) +
strlen(new_class_name) + 2*strlen(module_to_name);
msg = NEW_RESOURCE_ARRAY(char, len);
jio_snprintf(msg, len - 1,
jio_snprintf(msg, len,
"class %s (in module %s) cannot access class %s (in module %s) because module %s does not read module %s",
current_class_name, module_from_name, new_class_name,
module_to_name, module_from_name, module_to_name);
Expand All @@ -557,7 +557,7 @@ char* Reflection::verify_class_access_msg(const Klass* current_class,
size_t len = 160 + strlen(current_class_name) + 2*strlen(module_from_name) +
strlen(new_class_name) + 2*sizeof(uintx);
msg = NEW_RESOURCE_ARRAY(char, len);
jio_snprintf(msg, len - 1,
jio_snprintf(msg, len,
"class %s (in module %s) cannot access class %s (in unnamed module @0x%zx) because module %s does not read unnamed module @0x%zx",
current_class_name, module_from_name, new_class_name, uintx(identity_hash),
module_from_name, uintx(identity_hash));
Expand All @@ -573,7 +573,7 @@ char* Reflection::verify_class_access_msg(const Klass* current_class,
size_t len = 118 + strlen(current_class_name) + 2*strlen(module_from_name) +
strlen(new_class_name) + 2*strlen(module_to_name) + strlen(package_name);
msg = NEW_RESOURCE_ARRAY(char, len);
jio_snprintf(msg, len - 1,
jio_snprintf(msg, len,
"class %s (in module %s) cannot access class %s (in module %s) because module %s does not export %s to module %s",
current_class_name, module_from_name, new_class_name,
module_to_name, module_to_name, package_name, module_from_name);
Expand All @@ -584,7 +584,7 @@ char* Reflection::verify_class_access_msg(const Klass* current_class,
size_t len = 170 + strlen(current_class_name) + strlen(new_class_name) +
2*strlen(module_to_name) + strlen(package_name) + 2*sizeof(uintx);
msg = NEW_RESOURCE_ARRAY(char, len);
jio_snprintf(msg, len - 1,
jio_snprintf(msg, len,
"class %s (in unnamed module @0x%zx) cannot access class %s (in module %s) because module %s does not export %s to unnamed module @0x%zx",
current_class_name, uintx(identity_hash), new_class_name, module_to_name,
module_to_name, package_name, uintx(identity_hash));
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/services/diagnosticFramework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void DCmdParser::parse(CmdLine* line, char delim, TRAPS) {

strncpy(argbuf, iter.key_addr(), len);
argbuf[len] = '\0';
jio_snprintf(buf, buflen - 1, "Unknown argument '%s' in diagnostic command.", argbuf);
jio_snprintf(buf, buflen, "Unknown argument '%s' in diagnostic command.", argbuf);

THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), buf);
}
Expand Down Expand Up @@ -236,15 +236,15 @@ void DCmdParser::check(TRAPS) {
GenDCmdArgument* arg = _arguments_list;
while (arg != nullptr) {
if (arg->is_mandatory() && !arg->has_value()) {
jio_snprintf(buf, buflen - 1, "The argument '%s' is mandatory.", arg->name());
jio_snprintf(buf, buflen, "The argument '%s' is mandatory.", arg->name());
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), buf);
}
arg = arg->next();
}
arg = _options;
while (arg != nullptr) {
if (arg->is_mandatory() && !arg->has_value()) {
jio_snprintf(buf, buflen - 1, "The option '%s' is mandatory.", arg->name());
jio_snprintf(buf, buflen, "The option '%s' is mandatory.", arg->name());
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), buf);
}
arg = arg->next();
Expand Down