Skip to content

net.c: switch strncat(3) use to strlcat(3)#156

Open
ngie-eign wants to merge 2 commits into
corecode:masterfrom
ngie-eign:use-strlcat
Open

net.c: switch strncat(3) use to strlcat(3)#156
ngie-eign wants to merge 2 commits into
corecode:masterfrom
ngie-eign:use-strlcat

Conversation

@ngie-eign
Copy link
Copy Markdown
Contributor

@ngie-eign ngie-eign commented Jun 6, 2026

strlcat(3), unlike its predecessor (strncat(3)), NUL terminates buffers
when the buffer length meets or exceeds the provided dstsize.

Leveraging strlcat(3) instead of strncat(3) squashes compiler warnings,
and ensures the buffer is properly NUL terminated in the pathological case.

This is an alternative approach to the solution suggested in #77.

This will be leveraged in the next commit, resolving complaints from
compilers about the pathological case where strncat(3) is used in net.c .

Obtained from:	(DragonFlyBSD.org: lib/libc/string/strlcpy.c @ 667231f1)
Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
@ngie-eign
Copy link
Copy Markdown
Contributor Author

@ckujau: FYI.

strlcat(3), unlike its predecessor (strncat(3)), NUL terminates buffers
when the buffer length meets or exceeds the provided `dstsize`.

Leveraging strlcat(3) instead of strncat(3) squashes compiler warnings,
and ensures the buffer is properly NUL terminated in the pathological case.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
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