24 lines
866 B
Diff
24 lines
866 B
Diff
From 117dd05632cbc05ad54d5aa5da949835e09ef0f0 Mon Sep 17 00:00:00 2001
|
|
From: Zane <ticonci@users.noreply.github.com>
|
|
Date: Fri, 6 Jul 2018 11:03:24 +0800
|
|
Subject: [PATCH] fix compile warning with GCC8
|
|
|
|
---
|
|
src/netutils.c | 3 ++-
|
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/netutils.c b/src/netutils.c
|
|
index 66d0a7c..b7fcb64 100644
|
|
--- a/src/netutils.c
|
|
+++ b/src/netutils.c
|
|
@@ -85,7 +85,8 @@ setinterface(int socket_fd, const char *interface_name)
|
|
{
|
|
struct ifreq interface;
|
|
memset(&interface, 0, sizeof(struct ifreq));
|
|
- strncpy(interface.ifr_name, interface_name, IFNAMSIZ);
|
|
+ strncpy(interface.ifr_name, interface_name, IFNAMSIZ - 1);
|
|
+ interface.ifr_name[IFNAMSIZ - 1] = '\0';
|
|
int res = setsockopt(socket_fd, SOL_SOCKET, SO_BINDTODEVICE, &interface,
|
|
sizeof(struct ifreq));
|
|
return res;
|