Blame SOURCES/0001-libndp-fix-cppcheck-Undefined-behavior-Variable-buf-.patch

89129d
From 4376e752c822444f1a26b5e1e974ddd7104ae15c Mon Sep 17 00:00:00 2001
89129d
From: Jiri Pirko <jiri@resnulli.us>
89129d
Date: Wed, 18 Dec 2013 13:26:49 +0100
89129d
Subject: [patch] libndp: fix [cppcheck] Undefined behavior: Variable 'buf' is
89129d
 used as parameter and destination in s[n]printf()
89129d
89129d
cppcheck --enable=all --inconclusive --std=posix .
89129d
89129d
ndp_msg_opt_dnssl_domain():
89129d
			if (dom_len > len)
89129d
				return NULL;
89129d
89129d
			if (strlen(buf))
89129d
---->				sprintf(buf, "%s.", buf);
89129d
			buf[strlen(buf) + dom_len] = '\0';
89129d
			memcpy(buf + strlen(buf), ptr, dom_len);
89129d
89129d
So just use strcat instead.
89129d
89129d
Reported-by: Dan Williams <dcbw@redhat.com>
89129d
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
89129d
---
89129d
 libndp/libndp.c | 2 +-
89129d
 1 file changed, 1 insertion(+), 1 deletion(-)
89129d
89129d
diff --git a/libndp/libndp.c b/libndp/libndp.c
89129d
index 0bc3fe3..e510e2e 100644
89129d
--- a/libndp/libndp.c
89129d
+++ b/libndp/libndp.c
89129d
@@ -1540,7 +1540,7 @@ char *ndp_msg_opt_dnssl_domain(struct ndp_msg *msg, int offset,
89129d
 				return NULL;
89129d
 
89129d
 			if (strlen(buf))
89129d
-				sprintf(buf, "%s.", buf);
89129d
+				strcat(buf, ".");
89129d
 			buf[strlen(buf) + dom_len] = '\0';
89129d
 			memcpy(buf + strlen(buf), ptr, dom_len);
89129d
 			ptr += dom_len;
89129d
-- 
89129d
1.8.4.2
89129d