8332400: isspace argument should be a valid unsigned char

Reviewed-by: dholmes, amitkumar, stuefe, jwaters
This commit is contained in:
Robert Toyonaga 2024-06-14 09:32:52 +00:00 committed by Thomas Stuefe
parent 9b0a5c5cd0
commit cc64aeac47
8 changed files with 17 additions and 17 deletions
src
hotspot
java.base/share/native/libjli
jdk.hotspot.agent/linux/native/libsaproc
jdk.jdwp.agent/unix/native/libjdwp
jdk.jpackage/share/native/common

@ -661,7 +661,7 @@ bool CgroupController::read_numerical_key_value(const char* filename, const char
for (; line != nullptr; line = fgets(buf, buf_len, fp)) {
char after_key = line[key_len];
if (strncmp(line, key, key_len) == 0
&& isspace(after_key) != 0
&& isspace((unsigned char) after_key) != 0
&& after_key != '\n') {
// Skip key, skip space
const char* value_substr = line + key_len + 1;

@ -1356,7 +1356,7 @@ void os::Linux::capture_initial_stack(size_t max_size) {
i = 0;
if (s) {
// Skip blank chars
do { s++; } while (s && isspace(*s));
do { s++; } while (s && isspace((unsigned char) *s));
#define _UFM UINTX_FORMAT
#define _DFM INTX_FORMAT
@ -5222,7 +5222,7 @@ static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
if (s == nullptr) return -1;
// Skip blank chars
do { s++; } while (s && isspace(*s));
do { s++; } while (s && isspace((unsigned char) *s));
count = sscanf(s,"%c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu",
&cdummy, &idummy, &idummy, &idummy, &idummy, &idummy,

@ -748,7 +748,7 @@ static bool set_bool_flag(JVMFlag* flag, bool value, JVMFlagOrigin origin) {
static bool set_fp_numeric_flag(JVMFlag* flag, const char* value, JVMFlagOrigin origin) {
// strtod allows leading whitespace, but our flag format does not.
if (*value == '\0' || isspace(*value)) {
if (*value == '\0' || isspace((unsigned char) *value)) {
return false;
}
char* end;
@ -1178,13 +1178,13 @@ bool Arguments::process_settings_file(const char* file_name, bool should_exist,
if (c == '\n') in_comment = false;
} else {
if (c == '#') in_comment = true;
else if (!isspace(c)) {
else if (!isspace((unsigned char) c)) {
in_white_space = false;
token[pos++] = checked_cast<char>(c);
}
}
} else {
if (c == '\n' || (!in_quote && isspace(c))) {
if (c == '\n' || (!in_quote && isspace((unsigned char) c))) {
// token ends at newline, or at unquoted whitespace
// this allows a way to include spaces in string-valued options
token[pos] = '\0';
@ -3141,7 +3141,7 @@ jint Arguments::parse_options_buffer(const char* name, char* buffer, const size_
// parse all options
while (rd < buffer_end) {
// skip leading white space from the input string
while (rd < buffer_end && isspace(*rd)) {
while (rd < buffer_end && isspace((unsigned char) *rd)) {
rd++;
}
@ -3154,7 +3154,7 @@ jint Arguments::parse_options_buffer(const char* name, char* buffer, const size_
// Tokens are strings of non white space characters separated
// by one or more white spaces.
while (rd < buffer_end && !isspace(*rd)) {
while (rd < buffer_end && !isspace((unsigned char) *rd)) {
if (*rd == '\'' || *rd == '"') { // handle a quoted string
int quote = *rd; // matching quote to look for
rd++; // don't copy open quote

@ -45,7 +45,7 @@ CmdLine::CmdLine(const char* line, size_t len, bool no_command_name)
line_end = &line[len];
// Skip whitespace in the beginning of the line.
while (_cmd < line_end && isspace((int) _cmd[0])) {
while (_cmd < line_end && isspace((unsigned char) _cmd[0])) {
_cmd++;
}
cmd_end = _cmd;
@ -55,7 +55,7 @@ CmdLine::CmdLine(const char* line, size_t len, bool no_command_name)
_cmd_len = 0;
} else {
// Look for end of the command name
while (cmd_end < line_end && !isspace((int) cmd_end[0])) {
while (cmd_end < line_end && !isspace((unsigned char) cmd_end[0])) {
cmd_end++;
}
_cmd_len = cmd_end - _cmd;

@ -501,7 +501,7 @@ static jboolean expand(JLI_List args, const char *str, const char *var_name) {
// This is retained until the process terminates as it is saved as the args
p = JLI_MemAlloc(JLI_StrLen(str) + 1);
while (*str != '\0') {
while (*str != '\0' && isspace(*str)) {
while (*str != '\0' && isspace((unsigned char) *str)) {
str++;
}
@ -511,7 +511,7 @@ static jboolean expand(JLI_List args, const char *str, const char *var_name) {
}
arg = p;
while (*str != '\0' && !isspace(*str)) {
while (*str != '\0' && !isspace((unsigned char) *str)) {
if (inEnvVar && (*str == '"' || *str == '\'')) {
quote = *str++;
while (*str != quote && *str != '\0') {
@ -577,7 +577,7 @@ static jboolean expand(JLI_List args, const char *str, const char *var_name) {
exit(1);
}
assert (*str == '\0' || isspace(*str));
assert (*str == '\0' || isspace((unsigned char) *str));
}
return JNI_TRUE;

@ -242,7 +242,7 @@ static bool process_doesnt_exist(pid_t pid) {
found_state = true;
state = buf + state_len;
// Skip the spaces
while (isspace(*state)) {
while (isspace((unsigned char) *state)) {
state++;
}
// A state value of 'X' indicates that the thread is dead. 'Z'

@ -35,14 +35,14 @@
#include "error_messages.h"
static char *skipWhitespace(char *p) {
while ((*p != '\0') && isspace(*p)) {
while ((*p != '\0') && isspace((unsigned char) *p)) {
p++;
}
return p;
}
static char *skipNonWhitespace(char *p) {
while ((*p != '\0') && !isspace(*p)) {
while ((*p != '\0') && !isspace((unsigned char) *p)) {
p++;
}
return p;

@ -72,7 +72,7 @@ std::string makeMessage(const std::runtime_error& e, const SourceCodePos& pos) {
namespace {
bool isNotSpace(int chr) {
return isspace(chr) == 0;
return isspace((unsigned char) chr) == 0;
}