From 8173a6473e50a3bb0ff15e56644fa45268be84a4 Mon Sep 17 00:00:00 2001
From: patrick96
Date: Sun, 6 May 2018 18:33:10 +0200
Subject: [PATCH] fix(gcc): Fix -Wstringop-truncation warning
As mentioned in #1215, gcc >=8 will complain, if strncpy truncates the
source string or gcc can prove there is no NUL terminating byte.
This also updates the i3ipcpp submodule where there was a similar error
Fixes #1215
---
lib/i3ipcpp | 2 +-
src/adapters/net.cpp | 7 ++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/i3ipcpp b/lib/i3ipcpp
index a6aa7a19..d4e4786b 160000
--- a/lib/i3ipcpp
+++ b/lib/i3ipcpp
@@ -1 +1 @@
-Subproject commit a6aa7a19786bdf7b96a02900510b3b3c325c8bdf
+Subproject commit d4e4786be35b48d72dc7e59cf85ec34a90d129b5
diff --git a/src/adapters/net.cpp b/src/adapters/net.cpp
index 97d3b818..5d122005 100644
--- a/src/adapters/net.cpp
+++ b/src/adapters/net.cpp
@@ -159,7 +159,12 @@ namespace net {
driver.cmd = ETHTOOL_GDRVINFO;
memset(&request, 0, sizeof(request));
- strncpy(request.ifr_name, m_interface.c_str(), IFNAMSIZ - 0);
+
+ /*
+ * Only copy array size minus one bytes over to ensure there is a
+ * terminating NUL byte (which is guaranteed by memset)
+ */
+ strncpy(request.ifr_name, m_interface.c_str(), IFNAMSIZ - 1);
request.ifr_data = reinterpret_cast(&driver);