Skip to content

Conversation

@cold-brewed
Copy link
Contributor

Summary

Thanks to -Wstringop-truncation gcc is very particular about the use of strncpy.

It seems to be particularly concerned that

  • The destination string could, prior to the copy, potentially have no null terminator present
  • The length copied from the source string could potentially have no null terminator (because the length being copied is less than the source size)
  • If both of the above are true, the final dest string, after copy, could therefore have no null terminator

The fix for this is to explicitly set the null terminator which makes gcc happy.

Checklist

  • I have discussed this with core contributors already

References

A previous attempt to fix this accidentally broke zip loading and had to be undone in #4298

@OBattler OBattler merged commit 86c6cc2 into 86Box:master Mar 28, 2024
@cold-brewed cold-brewed deleted the gcc-warning-fix branch August 23, 2024 21:49
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.

2 participants