Blame SOURCES/0080-Include-count-for-0-character-when-using-strncpy-to-.patch

790dca
From 7d90f7603af6b59e7144cef6617a1e9dd42161bd Mon Sep 17 00:00:00 2001
790dca
From: Jes Sorensen <jsorensen@fb.com>
790dca
Date: Mon, 18 May 2020 20:19:53 -0400
790dca
Subject: [PATCH 080/108] Include count for \0 character when using strncpy to
790dca
 implement strdup.
790dca
790dca
We have to include the \0 character in the length when copying a
790dca
string with strncpy() for which length was found with strlen().
790dca
Otherwise the destination will not get null terminated - except that
790dca
we explicitly zeroed it out earlier.
790dca
790dca
This quiets down the compiler's warnings.
790dca
790dca
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
790dca
---
790dca
 dlink.c | 2 +-
790dca
 1 file changed, 1 insertion(+), 1 deletion(-)
790dca
790dca
diff --git a/dlink.c b/dlink.c
790dca
index 3efa94b..69aa7aa 100644
790dca
--- a/dlink.c
790dca
+++ b/dlink.c
790dca
@@ -63,7 +63,7 @@ char *dl_strndup(char *s, int l)
790dca
     if (s == NULL)
790dca
 	return NULL;
790dca
     n = dl_newv(char, l+1);
790dca
-    strncpy(n, s, l);
790dca
+    strncpy(n, s, l+1);
790dca
     n[l] = 0;
790dca
     return n;
790dca
 }
790dca
-- 
790dca
2.7.5
790dca