Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.
/ jdk22u Public archive

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 May 16, 2024
1 parent 0f3b3fa commit f5ce46f
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 @@ -327,16 +327,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 f5ce46f

@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.