Open
Conversation
Calling cctype functions, such as isspace, with negative values is undefined behaviour. While glibc allows it, it crashes on uClibc compiled without `UCLIBC_HAS_CTYPE_SIGNED`. Fixes the undefined behaviour by casting all arguments to cctype functions to `unsigned char`.
Fixes the following warnings
```
load_abc.cpp:2374:42: warning: ‘%ld’ directive writing between 1 and 20 bytes into a region of size 18 [-Wformat-overflow=]
2374 | sprintf(buf,"%s=-%ld",ABC_ENV_NORANDOMPICK,retval->pickrandom+2);
| ^~~
load_abc.cpp:2374:37: note: directive argument in the range [-9223372036854775806, 9223372036854775807]
2374 | sprintf(buf,"%s=-%ld",ABC_ENV_NORANDOMPICK,retval->pickrandom+2);
| ^~~~~~~~~
load_abc.cpp:2374:32: note: ‘sprintf’ output between 24 and 43 bytes into a destination of size 40
2374 | sprintf(buf,"%s=-%ld",ABC_ENV_NORANDOMPICK,retval->pickrandom+2);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
glebm
added a commit
to glebm/od-buildroot
that referenced
this pull request
Dec 23, 2022
Also sent upstream Konstanty/libmodplug#92 Signed-off-by: Gleb Mazovetskiy <glex.spb@gmail.com>
Author
|
@Konstanty Any chance you can merge this please? It's been tested by the OpenDingux community and it does resolve a few playback issues. Thanks |
Contributor
|
This looks OK, though I think this library still tries to target C++98. I would recommend C-style casts instead. (@Konstanty @sezero please correct me if I am wrong.) |
Author
|
|
Contributor
|
You're right, nevermind! |
glebm
added a commit
to glebm/od-buildroot
that referenced
this pull request
Mar 24, 2023
These are patches for libmodplug that fix various UB issues. They come from these PRs to the upstream repository: 1. Konstanty/libmodplug#92 2. Konstanty/libmodplug#93 The upstream maintainer has not merged any PRs in over a year. Fixes OpenDingux#105.
glebm
added a commit
to glebm/od-buildroot
that referenced
this pull request
Mar 24, 2023
These are patches for libmodplug that fix various UB issues. They come from these PRs to the upstream repository: 1. Konstanty/libmodplug#92 2. Konstanty/libmodplug#93 The upstream maintainer has not merged any PRs in over a year. Fixes OpenDingux#105. Signed-off-by: Gleb Mazovetskiy <glex.spb@gmail.com>
pcercuei
pushed a commit
to OpenDingux/buildroot
that referenced
this pull request
May 6, 2023
These are patches for libmodplug that fix various UB issues. They come from these PRs to the upstream repository: 1. Konstanty/libmodplug#92 2. Konstanty/libmodplug#93 The upstream maintainer has not merged any PRs in over a year. Fixes #105. Signed-off-by: Gleb Mazovetskiy <glex.spb@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Calling cctype functions, such as isspace, with negative values is undefined behaviour.
While glibc allows it, it crashes on uClibc compiled without
UCLIBC_HAS_CTYPE_SIGNED.Fixes the undefined behaviour by casting all arguments to cctype functions to
unsigned char.