From: Christian Brauner Date: Sat, 30 Jun 2018 09:41:23 +0000 (+0200) Subject: CODING_STYLE: add section about using strlcat() X-Git-Tag: lxc-2.0.10~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c13a1a0a3b5b7b045a8aff83358056f133acd1ed;p=thirdparty%2Flxc.git CODING_STYLE: add section about using strlcat() Signed-off-by: Christian Brauner --- diff --git a/CODING_STYLE.md b/CODING_STYLE.md index 784c5134e..7f2df9ed2 100644 --- a/CODING_STYLE.md +++ b/CODING_STYLE.md @@ -672,3 +672,13 @@ string. Unless you have a valid reason to accept truncation you must check whether truncation has occurred, treat it as an error, and handle the error appropriately. + +#### Use `strlcat()` instead of `strncat()` + +When concatenating strings always use `strlcat()` instead of `strncat()`. The +advantage of `strlcat()` is that it will always append a `\0` byte to the +string. + +Unless you have a valid reason to accept truncation you must check whether +truncation has occurred, treat it as an error, and handle the error +appropriately.