Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signed down cast negates usefulness of preceding bounds check #559

Closed
pgoodman opened this issue Sep 16, 2023 · 0 comments
Closed

Signed down cast negates usefulness of preceding bounds check #559

pgoodman opened this issue Sep 16, 2023 · 0 comments

Comments

@pgoodman
Copy link

Describe the bug
The following code checks that strtol doesn't read a negative number from the environment variable.
image
What the code should really do is check that ((int16_t) nthreads) > 0. That is, strtol could read in 65535, which is a non-negative long number. Then, the (highlighted) cast to an int16_t would interpret this as -1.

To Reproduce
Set BLOSC_NTHREADS environment variable to 65535.

System information:

  • OS: macOS
  • Compiler: Clang
  • Version: 16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant