Skip to content

Commit

Permalink
8329961: Buffer overflow in os::Linux::kernel_version
Browse files Browse the repository at this point in the history
Backport-of: 279ed0ddd505fb3052b818f755b4b220ed5557e6
  • Loading branch information
jerboaa committed Apr 15, 2024
1 parent eec41a4 commit f5c0d78
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,16 +321,9 @@ void os::Linux::kernel_version(long* major, long* minor) {
log_warning(os)("uname(2) failed to get kernel version: %s", os::errno_name(ret));
return;
}

char* walker = buffer.release;
long* set_v = major;
while (*minor == -1 && walker != nullptr) {
if (isdigit(walker[0])) {
*set_v = strtol(walker, &walker, 10);
set_v = minor;
} else {
++walker;
}
int nr_matched = sscanf(buffer.release, "%ld.%ld", major, minor);
if (nr_matched != 2) {
log_warning(os)("Parsing kernel version failed, expected 2 version numbers, only matched %d", nr_matched);
}
}

Expand Down

1 comment on commit f5c0d78

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.