]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
CODING_STYLE: add section about using strlcat()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 30 Jun 2018 09:41:23 +0000 (11:41 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 10 Dec 2018 13:39:57 +0000 (14:39 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
CODING_STYLE.md

index 784c5134ebbcaa8c9313a73702f1d67311fb283c..7f2df9ed2c178637eb5679e8c89523ded2de5267 100644 (file)
@@ -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.