# \[PATCH 09/18\] qlogic/qed: change strncpy+truncation to strlcpy

- From: Dominique Martinet \<asmadeus@codewreck.org\>
- Date: 2018-07-13 01:25:50 
- List: netdev
- Page: https://ratatoskr.run/netdev/2018/07/5331644

```text
Generated by scripts/coccinelle/misc/strncpy_truncation.cocci

Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
---

Please see https://marc.info/?l=linux-kernel&m=153144450722324&w=2 (the
first patch of the serie) for the motivation behind this patch

 drivers/net/ethernet/qlogic/qed/qed_debug.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_debug.c b/drivers/net/ethernet/qlogic/qed/qed_debug.c
index a14e48489029..4fe0a72230e8 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_debug.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_debug.c
@@ -6212,8 +6212,7 @@ static void qed_read_str_from_buf(void *buf, u32 *offset, u32 size, char *dest)
 {
 	const char *source_str = &((const char *)buf)[*offset];
 
-	strncpy(dest, source_str, size);
-	dest[size - 1] = '\0';
+	strlcpy(dest, source_str, size);
 	*offset += size;
 }
 
-- 
2.17.1
```
