Integrated: 8332400: isspace argument should be a valid unsigned char

Robert Toyonaga duke at openjdk.org
Fri Jun 14 09:35:19 UTC 2024


On Wed, 5 Jun 2024 20:08:10 GMT, Robert Toyonaga <duke at openjdk.org> wrote:

> ### Summary
> This change ensures we don't get undefined behavior when calling[`isspace`](https://pubs.opengroup.org/onlinepubs/007904975/functions/isspace.html).  `isspace` accepts an `int` argument that "the application shall ensure is a character representable as an unsigned char or equal to the value of the macro EOF.". 
> 
> Previously, there was no checking of the values passed to `isspace`. I've replaced direct calls with a new wrapper `os::is_space` that performs a range check and prevents the possibility of undefined behavior from happening. For instances outside of Hotspot, I've added casts to `unsigned char`. 
> 
> **Testing**
> - Added a new test in `test/hotspot/gtest/runtime/test_os.cpp` to check `os::is_space` is working correctly.
> - tier1

This pull request has now been integrated.

Changeset: cc64aeac
Author:    Robert Toyonaga <rtoyonag at redhat.com>
Committer: Thomas Stuefe <stuefe at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/cc64aeac47917f20a6d70e9796f0de9aa165ce62
Stats:     17 lines in 8 files changed: 0 ins; 0 del; 17 mod

8332400: isspace argument should be a valid unsigned char

Reviewed-by: dholmes, amitkumar, stuefe, jwaters

-------------

PR: https://git.openjdk.org/jdk/pull/19567


More information about the serviceability-dev mailing list