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 #76

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

String truncation warnings with newer GCC #76

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

Comments

@jphickey
Copy link
Contributor

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/cFS-GroundSystem/Subsystems/cmdUtil/cmdUtil.c:33:
In function ‘strncpy’,
    inlined from ‘main’ at /home/joe/code/cfecfs/github/tools/cFS-GroundSystem/Subsystems/cmdUtil/cmdUtil.c:413:13:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 10 equals destination size [-Werror=stringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
    inlined from ‘main’ at /home/joe/code/cfecfs/github/tools/cFS-GroundSystem/Subsystems/cmdUtil/cmdUtil.c:407: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));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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/cFS-GroundSystem that referenced this issue Apr 27, 2020
Fix possible nontruncated string in option 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 2.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