Skip to content

Commit

Permalink
8329961: Buffer overflow in os::Linux::kernel_version
Browse files Browse the repository at this point in the history
Reviewed-by: rehn, stuefe
  • Loading branch information
jdksjolen committed Apr 10, 2024
1 parent 9731b1c commit 279ed0d
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 @@ -377,16 +377,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

5 comments on commit 279ed0d

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@jerboaa
Copy link
Contributor

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@jerboaa
Copy link
Contributor

Choose a reason for hiding this comment

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

/backport jdk22u

@openjdk
Copy link

@openjdk openjdk bot commented on 279ed0d Apr 12, 2024

Choose a reason for hiding this comment

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

@jerboaa the backport was successfully created on the branch backport-jerboaa-279ed0dd in my personal fork of openjdk/jdk22u. To create a pull request with this backport targeting openjdk/jdk22u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 279ed0dd from the openjdk/jdk repository.

The commit being backported was authored by Johan Sjölen on 10 Apr 2024 and was reviewed by Robbin Ehn and Thomas Stuefe.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk22u:

$ git fetch https://github.com/openjdk-bots/jdk22u.git backport-jerboaa-279ed0dd:backport-jerboaa-279ed0dd
$ git checkout backport-jerboaa-279ed0dd
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk22u.git backport-jerboaa-279ed0dd

⚠️ @jerboaa You are not yet a collaborator in my fork openjdk-bots/jdk22u. An invite will be sent out and you need to accept it before you can proceed.

@openjdk
Copy link

@openjdk openjdk bot commented on 279ed0d Apr 12, 2024

Choose a reason for hiding this comment

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

@jerboaa the backport was successfully created on the branch backport-jerboaa-279ed0dd in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 279ed0dd from the openjdk/jdk repository.

The commit being backported was authored by Johan Sjölen on 10 Apr 2024 and was reviewed by Robbin Ehn and Thomas Stuefe.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-jerboaa-279ed0dd:backport-jerboaa-279ed0dd
$ git checkout backport-jerboaa-279ed0dd
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-jerboaa-279ed0dd

⚠️ @jerboaa You are not yet a collaborator in my fork openjdk-bots/jdk21u-dev. An invite will be sent out and you need to accept it before you can proceed.

Please sign in to comment.