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

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