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

Fix UB when calling cctype functions #92

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Dec 21, 2022

  1. Fix UB when calling cctype functions

    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`.
    glebm committed Dec 21, 2022
    Configuration menu
    Copy the full SHA
    dc6d599 View commit details
    Browse the repository at this point in the history
  2. Fix -wformat-overflow in ABC_Init

    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 committed Dec 21, 2022
    Configuration menu
    Copy the full SHA
    af012f4 View commit details
    Browse the repository at this point in the history