[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201016125216.10922-2-laniel_francis@privacyrequired.com>
Date: Fri, 16 Oct 2020 14:52:14 +0200
From: laniel_francis@...vacyrequired.com
To: linux-hardening@...r.kernel.org
Cc: Francis Laniel <laniel_francis@...vacyrequired.com>
Subject: [PATCH v1 1/3] Fix unefficient call to memset before memcpu in nla_strlcpy.
From: Francis Laniel <laniel_francis@...vacyrequired.com>
This patch solves part 1 of issue: https://github.com/KSPP/linux/issues/110
Signed-off-by: Francis Laniel <laniel_francis@...vacyrequired.com>
---
lib/nlattr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/nlattr.c b/lib/nlattr.c
index 74019c8ebf6b..ab96a5f4b9b8 100644
--- a/lib/nlattr.c
+++ b/lib/nlattr.c
@@ -731,8 +731,8 @@ size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dstsize)
if (dstsize > 0) {
size_t len = (srclen >= dstsize) ? dstsize - 1 : srclen;
- memset(dst, 0, dstsize);
memcpy(dst, src, len);
+ dst[len] = '\0';
}
return srclen;
--
2.20.1
Powered by blists - more mailing lists