strncat(9)
π strncat(9)
okay so this is a page from the Kernel API Manual and bestie, we need to talk about strncat. it's a whole situation. grab a snack. π
πΈ NAME πΈ
strncat β append a string to an existing string
like, the sequel to the string. the string part 2. the string electric boogaloo.
β¨ SYNOPSIS β¨
char * strncat (char * const p , const char * const q , __kernel_size_t
count );
π ARGUMENTS π
pβ pointer to aNUL-terminated string, and this is the one you're appending to. the main character, honestly. πqβ pointer to the source string you're appending from. the supporting role that still gets screentime.countβ the maximum number of bytes to read fromq. it's giving boundaries. we love boundaries. π¦
π DESCRIPTION π
so what it does: it appends at most count bytes from q (and it stops at the first NUL byte, no cap) after the NUL-terminated string at p. and p will be NUL-terminated. periodt. π
and then it returns p. that's it. that's the whole thing.
β οΈ okay so now the serious part, and i need you to actually listen: do not use this function. like, at all. not me being dramatic, it's literally on the page.
here's the tea β while FORTIFY_SOURCE tries to avoid read and write overflows, that's only possible when the sizes of p and q are known to the compiler. so if the compiler doesn't know? no protection. none. π
instead, prefer building the string with formatting, via scnprintf or similar. that's the vibe. that's the move. π«Ά
π SEE ALSO π
- Kernel file
./include/linux/fortify-string.h unsafe_memcpy(9)strnlen(9)strlen(9)strlcat(9)strcat(9)strcpy(9)
the whole string function friend group, basically. they all show up to the group chat. π§
and that's the page, bestie! this one came out of ./include/linux in October 2026 β so like, remember to check that date if you're citing it, because nothing's more embarrassing than citing a stale manpage. π anyway ily, go use scnprintf, and stay safe out there. πΈπ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms