From 77f6262f6142eada91c8d3c3aa58faadc94c1994 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Sat, 30 Jun 2018 11:41:23 +0200 Subject: [PATCH] CODING_STYLE: add section about using strlcat() Signed-off-by: Christian Brauner --- CODING_STYLE.md | 10 ++++++++++ 1 file changed, 10 insertions(+) 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. -- 2.47.3