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

hardfault_log: fix NULL terminator truncation #12284

Merged
merged 1 commit into from
Jun 17, 2019
Merged

Conversation

bruenn
Copy link
Contributor

@bruenn bruenn commented Jun 15, 2019

building "make omnibus_f4sd_default" with gcc 8.2.1 failes with:
hardfault_log.c:315:7: error: 'strncat' specified bound 30 equals destination size

gcc8 introduced -Wstringop-truncation, which will warn about NULL terminator
truncation.

This patch fixes two similar issues:

  • strncpy() makes no sense if we want to copy without NULL terminator
  • strncat() needs space to append the NULL terminator

fixes #12283

Please use PX4 Discuss or Slack to align on pull requests if necessary. You can then open draft pull requests to get early feedback.

Describe problem solved by the proposed pull request
A clear and concise description of the problem this proposed change will solve. E.g. For this use case I ran into...

Test data / coverage
How was it tested? What cases were covered? Logs uploaded to https://review.px4.io/ and screenshots of the important plot parts.

Describe your preferred solution
A clear and concise description of what you have implemented.

Describe possible alternatives
A clear and concise description of alternative solutions or features you've considered.

Additional context
Add any other related context or media.

building "make omnibus_f4sd_default" with gcc 8.2.1 failes with:
hardfault_log.c:315:7: error: 'strncat' specified bound 30 equals destination size

gcc8 introduced -Wstringop-truncation, which will warn about NULL terminator
truncation.

This patch fixes two similar issues:
- strncpy() makes no sense if we want to copy without NULL terminator
- strncat() needs space to append the NULL terminator

fixes PX4#12283
@bkueng bkueng merged commit b402c96 into PX4:master Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make omnibus_f4sd_default is broken for gcc 8.2.1
2 participants