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

New GCC warnings causing build failure [-Werror=stringop-overflow=] #55

Closed
2 tasks done
thnkslprpt opened this issue Nov 6, 2022 · 2 comments
Closed
2 tasks done
Assignees
Labels

Comments

@thnkslprpt
Copy link
Contributor

Checklist

  • I reviewed the Contributing Guide.
  • I performed a cursory search to see if the bug report is relevant, not redundant, nor in conflict with other tickets.

Describe the bug
I believe these are newly triggered GCC warnings (treated as errors) that are now causing the standard MM Build + Run workflow to fail.

In function ‘strncat’,
    inlined from ‘MM_DumpInEventCmd’ at /home/runner/work/MM/MM/apps/mm/fsw/src/mm_dump.c:530:25:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:136:10: error: ‘__builtin___strncat_chk’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
  136 |   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/MM/MM/apps/mm/fsw/src/mm_dump.c: In function ‘MM_DumpInEventCmd’:
/home/runner/work/MM/MM/apps/mm/fsw/src/mm_dump.c:530:25: note: length computed here
  530 |                         strncat(EventString, TempString, strlen(TempString));
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/string.h:495,
...
In function ‘strncat’,
    inlined from ‘MM_DumpInEventCmd’ at /home/runner/work/MM/MM/apps/mm/fsw/src/mm_dump.c:539:21:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:136:10: error: ‘__builtin___strncat_chk’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
  136 |   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/MM/MM/apps/mm/fsw/src/mm_dump.c: In function ‘MM_DumpInEventCmd’:
/home/runner/work/MM/MM/apps/mm/fsw/src/mm_dump.c:539:21: note: length computed here
  539 |                     strncat(EventString, TempString, strlen(TempString));
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

To Reproduce
Run the Build + Run GitHub Action on the current main branch MM source code.

Expected behavior
Build + Run workflow should run without errors.

Reporter Info
Avi @thnkslprpt

@jphickey
Copy link
Contributor

This is definitely some incorrect use of strncat. Should fix.

@chillfig
Copy link
Contributor

The code that created this build failure is risky because it does not consider the remaining capacity of "EventString". This can potentially lead to buffer overflow. However, changes were since then added to mm_dump.c specifically to safeguard against bufferflow. These changes can be found here: #69
Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants