Skip to content

Commit

Permalink
Backport 992b6c464a9655438a808cf2e1979e04356123be
Browse files Browse the repository at this point in the history
  • Loading branch information
ktakakuri committed Jan 25, 2024
1 parent 552c686 commit b62ee29
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions hotspot/src/share/vm/runtime/arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,18 +595,25 @@ char* SysClassPath::add_jars_to_path(char* path, const char* directory) {
// Parses a memory size specification string.
static bool atomull(const char *s, julong* result) {
julong n = 0;
int args_read = sscanf(s, JULONG_FORMAT, &n);
if (args_read != 1) {

// First char must be a digit. Don't allow negative numbers or leading spaces.
if (!isdigit(*s)) {
return false;
}
while (*s != '\0' && isdigit(*s)) {
s++;

char* remainder;
errno = 0;
n = strtoull(s, &remainder, 10);
if (errno != 0) {
return false;
}
// 4705540: illegal if more characters are found after the first non-digit
if (strlen(s) > 1) {

// Fail if no number was read at all or if the remainder contains more than a single non-digit character.
if (remainder == s || strlen(remainder) > 1) {
return false;
}
switch (*s) {

switch (*remainder) {
case 'T': case 't':
*result = n * G * K;
// Check for overflow.
Expand Down

0 comments on commit b62ee29

Please sign in to comment.