---
name: "pmstrncat"
section: "3"
platform: "linux"
package: "pcp"
version: "7.2.2-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/pmstrncat"
---

# pmstrncat(3)

safe string concatenation

## NAME

**pmstrncat** - safe string concatenation

## C SYNOPSIS

**#include \<pcp/pmapi.h\>**

**int pmstrncat(char \****dest***, size\_t** *destlen***, char \****src***);**

**cc ... -lpcp**

## DESCRIPTION

**pmstrncat** is safe string concatenation routine with semantics similar to [**strncat**(3)](/strncat/3.md).

The main differences between **pmstrncat** and [**strncat**(3)](/strncat/3.md) 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 for **strncat**

- •

  the length argument has the same semantics for **pmstrncat** and [**pmstrncpy**(3)](/pmstrncpy/3.md), unlike [**strncat**(3)](/strncat/3.md) and [**strncpy**(3)](/strncpy/3.md).

- •

  the return value from **pmstrncat** is useful

- •

  the order of the arguments for **pmstrncat** has been *deliberately* changed from the order of the arguments for [**strncat**(3)](/strncat/3.md) 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.

## HISTORY

[**strncat**(3)](/strncat/3.md) first appeared in Edition 7 AT&T Unix around 1979. It was specifically crafted to construct file pathnames (which needed to be null-byte terminated) from component names from on-disk directory entries that were of a fixed maximum size and may have zero, one or more trailing null-bytes

The subsequent attempts to use [**strncat**(3)](/strncat/3.md) for more generally string concatenation operations has been fraught with abuse and security issues; **pmstrncat** is an attempt to address these problems.

## SEE ALSO

[**PMAPI**(3)](/PMAPI/3.md), [**pmstrncpy**(3)](/pmstrncpy/3.md), [**strncat**(3)](/strncat/3.md) and [**strncpy**(3)](/strncpy/3.md).
