Skip to content

Comments

Ensure that strings copied by strncpy() are NUL-terminated#28

Open
scfc wants to merge 1 commit intogumpu:releasefrom
scfc:fix-strncpy-usage
Open

Ensure that strings copied by strncpy() are NUL-terminated#28
scfc wants to merge 1 commit intogumpu:releasefrom
scfc:fix-strncpy-usage

Conversation

@scfc
Copy link

@scfc scfc commented Apr 16, 2025

strncpy() does not guarantee that the destination buffer will be NUL-terminated, so this change ensures that by explicitly setting the last element to NUL.

POSIX.1-2024 defines the function strlcpy() for that purpose, but given the standard's freshness and the limited number of occurrences in ROBODoc's source code, it was easier just to amend the few uses.

strncpy() does not guarantee that the destination buffer will be
NUL-terminated, so this change ensures that by explicitly setting the
last element to NUL.

POSIX.1-2024 defines the function strlcpy() for that purpose, but
given the standard's freshness and the limited number of occurrences
in ROBODoc's source code, it was easier just to amend the few uses.
@scfc scfc force-pushed the fix-strncpy-usage branch from 2157ee4 to 10c93b2 Compare April 17, 2025 07:19
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.

1 participant