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

String truncation warnings with newer GCC #37

Closed
jphickey opened this issue Apr 27, 2020 · 0 comments · Fixed by #38 or #41
Closed

String truncation warnings with newer GCC #37

jphickey opened this issue Apr 27, 2020 · 0 comments · Fixed by #38 or #41
Labels
bug Something isn't working
Milestone

Comments

@jphickey
Copy link
Contributor

jphickey commented Apr 27, 2020

Describe the bug
Ubuntu has released 20.04 LTS which includes GCC 9.3.0. When using this compiler it implements a much stricter (and often over-zealous) checking of string ops.

For instance:

In file included from /usr/include/string.h:495,
                 from /home/joe/code/cfecfs/github/tools/elf2cfetbl/elf2cfetbl.c:34:
In function ‘strncpy’,
    inlined from ‘ProcessCmdLineOptions’ at /home/joe/code/cfecfs/github/tools/elf2cfetbl/elf2cfetbl.c:945:13:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 32 equals destination size [-Werror=stringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘ProcessCmdLineOptions’ at /home/joe/code/cfecfs/github/tools/elf2cfetbl/elf2cfetbl.c:939:13:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 38 equals destination size [-Werror=stringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

To Reproduce
Build code with default config using GCC 9.3.0, with optimization enabled and full warnings.

Expected behavior
Code should build cleanly.

System observed on:
Ubuntu 20.04 LTS 64 bit.

Reporter Info
Joseph Hickey, Vantage Systems, Inc.

jphickey added a commit to jphickey/elf2cfetbl that referenced this issue Apr 27, 2020
Fix possible non-termination of strings within command line parsing.
This generated a warning in GCC9.
astrogeco added a commit that referenced this issue May 8, 2020
@astrogeco astrogeco added the bug Something isn't working label Oct 1, 2020
@astrogeco astrogeco added this to the 3.2.0 milestone Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants