diff mbox series

[oe,meta-networking,2/3] lowpan-tools: Fix build with gcc-8

Message ID 20180601045815.15819-2-raj.khem@gmail.com
State Accepted
Commit 24c24fba961e4d231bd5d7a233e11a06c41a8053
Headers show
Series [oe,meta-oe,1/3] fwts: Upgrade to V18.05.00 | expand

Commit Message

Khem Raj June 1, 2018, 4:58 a.m. UTC
Signed-off-by: Khem Raj <raj.khem@gmail.com>

---
 ...tential-string-truncation-in-strncpy.patch | 139 ++++++++++++++++++
 .../lowpan-tools/lowpan-tools_git.bb          |   1 +
 2 files changed, 140 insertions(+)
 create mode 100644 meta-networking/recipes-support/lowpan-tools/lowpan-tools/0001-Fix-potential-string-truncation-in-strncpy.patch

-- 
2.17.1

-- 
_______________________________________________
Openembedded-devel mailing list
Openembedded-devel@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-devel
diff mbox series

Patch

diff --git a/meta-networking/recipes-support/lowpan-tools/lowpan-tools/0001-Fix-potential-string-truncation-in-strncpy.patch b/meta-networking/recipes-support/lowpan-tools/lowpan-tools/0001-Fix-potential-string-truncation-in-strncpy.patch
new file mode 100644
index 0000000000..e621d8f2a8
--- /dev/null
+++ b/meta-networking/recipes-support/lowpan-tools/lowpan-tools/0001-Fix-potential-string-truncation-in-strncpy.patch
@@ -0,0 +1,139 @@ 
+From 58b6d9a2efe101e5b80fd708e6f84c7ca779ce93 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 31 May 2018 20:27:43 -0700
+Subject: [PATCH] Fix potential string truncation in strncpy()
+
+GCC 8 complains about the string truncation during copy
+
+error: 'strncpy' specified bound 16 equals destination size
+
+Upstream-Status: Inappropriate [depricated component]
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ tests/listen-packet.c | 3 ++-
+ tests/listen.c        | 3 ++-
+ tests/test2.c         | 4 ++--
+ tests/test3.c         | 3 ++-
+ tests/test4.c         | 3 ++-
+ tests/test5.c         | 3 ++-
+ tests/test6.c         | 3 ++-
+ tests/test7.c         | 3 ++-
+ 8 files changed, 16 insertions(+), 9 deletions(-)
+
+diff --git a/tests/listen-packet.c b/tests/listen-packet.c
+index e40af81..eae0c71 100644
+--- a/tests/listen-packet.c
++++ b/tests/listen-packet.c
+@@ -50,7 +50,8 @@ int main(int argc, char **argv) {
+ 		return 1;
+ 	}
+ 
+-	strncpy(req.ifr_name, iface, IF_NAMESIZE);
++	strncpy(req.ifr_name, iface, IF_NAMESIZE - 1);
++	req.ifr_name[IF_NAMESIZE - 1] = '\0';
+ 	ret = ioctl(sd, SIOCGIFINDEX, &req);
+ 	if (ret < 0)
+ 		perror("ioctl: SIOCGIFINDEX");
+diff --git a/tests/listen.c b/tests/listen.c
+index 75c320b..5ce1ed9 100644
+--- a/tests/listen.c
++++ b/tests/listen.c
+@@ -47,7 +47,8 @@ int main(int argc, char **argv) {
+ 		return 1;
+ 	}
+ 
+-	strncpy(req.ifr_name, iface, IFNAMSIZ);
++	strncpy(req.ifr_name, iface, IFNAMSIZ - 1);
++	req.ifr_name[IF_NAMESIZE - 1] = '\0';
+ 	ret = ioctl(sd, SIOCGIFHWADDR, &req);
+ 	if (ret < 0)
+ 		perror("ioctl: SIOCGIFHWADDR");
+diff --git a/tests/test2.c b/tests/test2.c
+index 58eb74b..5d02838 100644
+--- a/tests/test2.c
++++ b/tests/test2.c
+@@ -45,8 +45,8 @@ int main(int argc, char **argv) {
+ 		perror("socket");
+ 		return 1;
+ 	}
+-
+-	strncpy(req.ifr_name, argv[1] ?: "wpan0", IF_NAMESIZE);
++	strncpy(req.ifr_name, argv[1] ?: "wpan0", IF_NAMESIZE - 1);
++	req.ifr_name[IF_NAMESIZE - 1] = '\0';
+ 	ret = ioctl(sd, SIOCGIFHWADDR, &req);
+ 	if (ret < 0)
+ 		perror("ioctl: SIOCGIFHWADDR");
+diff --git a/tests/test3.c b/tests/test3.c
+index fb36627..2f50a5a 100644
+--- a/tests/test3.c
++++ b/tests/test3.c
+@@ -46,7 +46,8 @@ int main(int argc, char **argv) {
+ 		return 1;
+ 	}
+ 
+-	strncpy(req.ifr_name, argv[1] ?: "wpan0", IF_NAMESIZE);
++	strncpy(req.ifr_name, argv[1] ?: "wpan0", IF_NAMESIZE - 1);
++	req.ifr_name[IF_NAMESIZE - 1] = '\0';
+ 	ret = ioctl(sd, SIOCGIFHWADDR, &req);
+ 	if (ret < 0)
+ 		perror("ioctl: SIOCGIFHWADDR");
+diff --git a/tests/test4.c b/tests/test4.c
+index 33c274c..8737149 100644
+--- a/tests/test4.c
++++ b/tests/test4.c
+@@ -46,7 +46,8 @@ int main(int argc, char **argv) {
+ 		return 1;
+ 	}
+ 
+-	strncpy(req.ifr_name, argv[1] ?: "wpan0", IF_NAMESIZE);
++	strncpy(req.ifr_name, argv[1] ?: "wpan0", IF_NAMESIZE - 1);
++	req.ifr_name[IF_NAMESIZE - 1] = '\0';
+ 	ret = ioctl(sd, SIOCGIFHWADDR, &req);
+ 	if (ret < 0)
+ 		perror("ioctl: SIOCGIFHWADDR");
+diff --git a/tests/test5.c b/tests/test5.c
+index 4439dfa..28db562 100644
+--- a/tests/test5.c
++++ b/tests/test5.c
+@@ -45,7 +45,8 @@ int main(int argc, char **argv) {
+ 		return 1;
+ 	}
+ 
+-	strncpy(req.ifr_name, argv[1] ?: "wpan0", IF_NAMESIZE);
++	strncpy(req.ifr_name, argv[1] ?: "wpan0", IF_NAMESIZE - 1);
++	req.ifr_name[IF_NAMESIZE - 1] = '\0';
+ 	ret = ioctl(sd, SIOCGIFADDR, &req);
+ 	if (ret < 0) {
+ 		perror("ioctl: SIOCGIFADDR");
+diff --git a/tests/test6.c b/tests/test6.c
+index e375bfb..ce7de59 100644
+--- a/tests/test6.c
++++ b/tests/test6.c
+@@ -45,7 +45,8 @@ int main(int argc, char **argv) {
+ 		return 1;
+ 	}
+ 
+-	strncpy(req.ifr_name, argv[1] ?: "wpan0", IF_NAMESIZE);
++	strncpy(req.ifr_name, argv[1] ?: "wpan0", IF_NAMESIZE - 1);
++	req.ifr_name[IF_NAMESIZE - 1] = '\0';
+ 	ret = ioctl(sd, SIOCGIFADDR, &req);
+ 	if (ret < 0) {
+ 		perror("ioctl: SIOCGIFADDR");
+diff --git a/tests/test7.c b/tests/test7.c
+index e9a5a55..37da22d 100644
+--- a/tests/test7.c
++++ b/tests/test7.c
+@@ -58,7 +58,8 @@ int main(int argc, char **argv) {
+ 	if (ret)
+ 		perror("setsockopt");
+ 
+-	strncpy(req.ifr_name, argv[1] ?: "wpan0", IF_NAMESIZE);
++	strncpy(req.ifr_name, argv[1] ?: "wpan0", IF_NAMESIZE - 1);
++	req.ifr_name[IF_NAMESIZE - 1] = '\0';
+ 	ret = ioctl(sd, SIOCGIFHWADDR, &req);
+ 	if (ret < 0)
+ 		perror("ioctl: SIOCGIFHWADDR");
+-- 
+2.17.1
+
diff --git a/meta-networking/recipes-support/lowpan-tools/lowpan-tools_git.bb b/meta-networking/recipes-support/lowpan-tools/lowpan-tools_git.bb
index d0fe59c983..b70c43f156 100644
--- a/meta-networking/recipes-support/lowpan-tools/lowpan-tools_git.bb
+++ b/meta-networking/recipes-support/lowpan-tools/lowpan-tools_git.bb
@@ -15,6 +15,7 @@  SRC_URI = "git://github.com/linux-wpan/lowpan-tools \
            file://0001-src-iz.c-Undef-dprintf-before-redefining.patch \
            file://0001-Remove-newline-from-format-line.patch \
            file://0001-coordinator-Fix-strncpy-range-warning.patch \
+           file://0001-Fix-potential-string-truncation-in-strncpy.patch \
            "
 SRCREV = "1c2d8674cc6f4b1166a066e8822e295c105ae7a2"