pmstrncat3
Safe string concatenation
C synopsis
#include <pcp/pmapi.h>
int pmstrncat(char *dest, size_t destlen, char *src);
cc ... -lpcp
Overview
pmstrncat is safe string concatenation routine with semantics similar to strncat(3).
The main differences between pmstrncat and strncat(3) are:
- •
-
src must be null-byte terminated for
pmstrncat
- •
-
destlen is the length of the destination buffer (dest) for
pmstrncat,not the maximum number of non-null bytes to copy from src as it is forstrncat
- •
-
the length argument has the same semantics for
pmstrncatand pmstrncpy(3), unlike strncat(3) and strncpy(3).
- •
-
the return value from
pmstrncatis useful
- •
-
the order of the arguments for
pmstrncathas been deliberately changed from the order of the arguments for strncat(3) to avoid accidental misuse that a compiler can easily detect
On success, pmstrncat returns 0, else -1 indicates that src is too big and the result been truncated to ensure dest has not been overrun.
Releases
3 releases since Debian 12 (Bookworm); the text changed 2 times.