diff --git a/CODING_STYLE.md b/CODING_STYLE.md index 24c6d3603..784c5134e 100644 --- a/CODING_STYLE.md +++ b/CODING_STYLE.md @@ -662,3 +662,13 @@ rules to use them: #endif }; ``` + +#### Use `strlcpy()` instead of `strncpy()` + +When copying strings always use `strlcpy()` instead of `strncpy()`. The +advantage of `strlcpy()` 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.