Skip to content

Fix strncpy buffer truncation warning in ini.c#148

Merged
xuhdev merged 2 commits intoeditorconfig:masterfrom
liweiganga:master
Dec 21, 2025
Merged

Fix strncpy buffer truncation warning in ini.c#148
xuhdev merged 2 commits intoeditorconfig:masterfrom
liweiganga:master

Conversation

@liweiganga
Copy link
Contributor

  • Replace strncpy(dest, src, size) with strncpy(dest, src, size - 1) in strncpy0() function to prevent GCC -Wstringop-truncation warning when destination size equals buffer size
  • Ensure null-termination with dest[size - 1] = '\0' for safety
  • This maintains backward compatibility while addressing compiler security warning

#147

- Replace strncpy(dest, src, size) with strncpy(dest, src, size - 1) in strncpy0()
  function to prevent GCC -Wstringop-truncation warning when destination size
  equals buffer size
- Ensure null-termination with dest[size - 1] = '\0' for safety
- This maintains backward compatibility while addressing compiler security warning
Copy link
Member

@xuhdev xuhdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@xuhdev xuhdev enabled auto-merge (squash) December 21, 2025 06:57
@xuhdev xuhdev merged commit 750c39e into editorconfig:master Dec 21, 2025
12 checks passed
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