Skip to content

Commit cc64aea

Browse files
roberttoyonagatstuefe
authored andcommitted
8332400: isspace argument should be a valid unsigned char
Reviewed-by: dholmes, amitkumar, stuefe, jwaters
1 parent 9b0a5c5 commit cc64aea

File tree

8 files changed

+17
-17
lines changed

8 files changed

+17
-17
lines changed

src/hotspot/os/linux/cgroupSubsystem_linux.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ bool CgroupController::read_numerical_key_value(const char* filename, const char
661661
for (; line != nullptr; line = fgets(buf, buf_len, fp)) {
662662
char after_key = line[key_len];
663663
if (strncmp(line, key, key_len) == 0
664-
&& isspace(after_key) != 0
664+
&& isspace((unsigned char) after_key) != 0
665665
&& after_key != '\n') {
666666
// Skip key, skip space
667667
const char* value_substr = line + key_len + 1;

src/hotspot/os/linux/os_linux.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ void os::Linux::capture_initial_stack(size_t max_size) {
13561356
i = 0;
13571357
if (s) {
13581358
// Skip blank chars
1359-
do { s++; } while (s && isspace(*s));
1359+
do { s++; } while (s && isspace((unsigned char) *s));
13601360

13611361
#define _UFM UINTX_FORMAT
13621362
#define _DFM INTX_FORMAT
@@ -5222,7 +5222,7 @@ static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
52225222
if (s == nullptr) return -1;
52235223

52245224
// Skip blank chars
5225-
do { s++; } while (s && isspace(*s));
5225+
do { s++; } while (s && isspace((unsigned char) *s));
52265226

52275227
count = sscanf(s,"%c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu",
52285228
&cdummy, &idummy, &idummy, &idummy, &idummy, &idummy,

src/hotspot/share/runtime/arguments.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ static bool set_bool_flag(JVMFlag* flag, bool value, JVMFlagOrigin origin) {
748748

749749
static bool set_fp_numeric_flag(JVMFlag* flag, const char* value, JVMFlagOrigin origin) {
750750
// strtod allows leading whitespace, but our flag format does not.
751-
if (*value == '\0' || isspace(*value)) {
751+
if (*value == '\0' || isspace((unsigned char) *value)) {
752752
return false;
753753
}
754754
char* end;
@@ -1178,13 +1178,13 @@ bool Arguments::process_settings_file(const char* file_name, bool should_exist,
11781178
if (c == '\n') in_comment = false;
11791179
} else {
11801180
if (c == '#') in_comment = true;
1181-
else if (!isspace(c)) {
1181+
else if (!isspace((unsigned char) c)) {
11821182
in_white_space = false;
11831183
token[pos++] = checked_cast<char>(c);
11841184
}
11851185
}
11861186
} else {
1187-
if (c == '\n' || (!in_quote && isspace(c))) {
1187+
if (c == '\n' || (!in_quote && isspace((unsigned char) c))) {
11881188
// token ends at newline, or at unquoted whitespace
11891189
// this allows a way to include spaces in string-valued options
11901190
token[pos] = '\0';
@@ -3141,7 +3141,7 @@ jint Arguments::parse_options_buffer(const char* name, char* buffer, const size_
31413141
// parse all options
31423142
while (rd < buffer_end) {
31433143
// skip leading white space from the input string
3144-
while (rd < buffer_end && isspace(*rd)) {
3144+
while (rd < buffer_end && isspace((unsigned char) *rd)) {
31453145
rd++;
31463146
}
31473147

@@ -3154,7 +3154,7 @@ jint Arguments::parse_options_buffer(const char* name, char* buffer, const size_
31543154

31553155
// Tokens are strings of non white space characters separated
31563156
// by one or more white spaces.
3157-
while (rd < buffer_end && !isspace(*rd)) {
3157+
while (rd < buffer_end && !isspace((unsigned char) *rd)) {
31583158
if (*rd == '\'' || *rd == '"') { // handle a quoted string
31593159
int quote = *rd; // matching quote to look for
31603160
rd++; // don't copy open quote

src/hotspot/share/services/diagnosticFramework.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ CmdLine::CmdLine(const char* line, size_t len, bool no_command_name)
4545
line_end = &line[len];
4646

4747
// Skip whitespace in the beginning of the line.
48-
while (_cmd < line_end && isspace((int) _cmd[0])) {
48+
while (_cmd < line_end && isspace((unsigned char) _cmd[0])) {
4949
_cmd++;
5050
}
5151
cmd_end = _cmd;
@@ -55,7 +55,7 @@ CmdLine::CmdLine(const char* line, size_t len, bool no_command_name)
5555
_cmd_len = 0;
5656
} else {
5757
// Look for end of the command name
58-
while (cmd_end < line_end && !isspace((int) cmd_end[0])) {
58+
while (cmd_end < line_end && !isspace((unsigned char) cmd_end[0])) {
5959
cmd_end++;
6060
}
6161
_cmd_len = cmd_end - _cmd;

src/java.base/share/native/libjli/args.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ static jboolean expand(JLI_List args, const char *str, const char *var_name) {
501501
// This is retained until the process terminates as it is saved as the args
502502
p = JLI_MemAlloc(JLI_StrLen(str) + 1);
503503
while (*str != '\0') {
504-
while (*str != '\0' && isspace(*str)) {
504+
while (*str != '\0' && isspace((unsigned char) *str)) {
505505
str++;
506506
}
507507

@@ -511,7 +511,7 @@ static jboolean expand(JLI_List args, const char *str, const char *var_name) {
511511
}
512512

513513
arg = p;
514-
while (*str != '\0' && !isspace(*str)) {
514+
while (*str != '\0' && !isspace((unsigned char) *str)) {
515515
if (inEnvVar && (*str == '"' || *str == '\'')) {
516516
quote = *str++;
517517
while (*str != quote && *str != '\0') {
@@ -577,7 +577,7 @@ static jboolean expand(JLI_List args, const char *str, const char *var_name) {
577577
exit(1);
578578
}
579579

580-
assert (*str == '\0' || isspace(*str));
580+
assert (*str == '\0' || isspace((unsigned char) *str));
581581
}
582582

583583
return JNI_TRUE;

src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ static bool process_doesnt_exist(pid_t pid) {
242242
found_state = true;
243243
state = buf + state_len;
244244
// Skip the spaces
245-
while (isspace(*state)) {
245+
while (isspace((unsigned char) *state)) {
246246
state++;
247247
}
248248
// A state value of 'X' indicates that the thread is dead. 'Z'

src/jdk.jdwp.agent/unix/native/libjdwp/exec_md.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@
3535
#include "error_messages.h"
3636

3737
static char *skipWhitespace(char *p) {
38-
while ((*p != '\0') && isspace(*p)) {
38+
while ((*p != '\0') && isspace((unsigned char) *p)) {
3939
p++;
4040
}
4141
return p;
4242
}
4343

4444
static char *skipNonWhitespace(char *p) {
45-
while ((*p != '\0') && !isspace(*p)) {
45+
while ((*p != '\0') && !isspace((unsigned char) *p)) {
4646
p++;
4747
}
4848
return p;

src/jdk.jpackage/share/native/common/ErrorHandling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ std::string makeMessage(const std::runtime_error& e, const SourceCodePos& pos) {
7272
namespace {
7373

7474
bool isNotSpace(int chr) {
75-
return isspace(chr) == 0;
75+
return isspace((unsigned char) chr) == 0;
7676
}
7777

7878

0 commit comments

Comments
 (0)