[PATCH] fix cid 1350009

Michael Adam obnox at samba.org
Wed Feb 3 10:43:07 UTC 2016


Review/push appreciated.

Thanks - Michael
-------------- next part --------------
From 267367964c957af33c8dded90bb61c009ed29039 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 3 Feb 2016 11:41:23 +0100
Subject: [PATCH] lib:socket: fix CID 1350009 - illegal memory accesses 
 (BUFFER_SIZE_WARNING)

Signed-off-by: Michael Adam <obnox at samba.org>
---
 lib/socket/interfaces.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/socket/interfaces.c b/lib/socket/interfaces.c
index f0386c0..c1229f2 100644
--- a/lib/socket/interfaces.c
+++ b/lib/socket/interfaces.c
@@ -140,7 +140,8 @@ static void query_iface_speed_from_name(const char *name, uint64_t *speed)
 		return;
 	}
 
-	strncpy(ifr.ifr_name, name, IF_NAMESIZE);
+	strncpy(ifr.ifr_name, name, IF_NAMESIZE - 1);
+	ifr.ifr_name[IF_NAMESIZE] = '\0';
 
 	ifr.ifr_data = (void *)&edata;
 	edata.cmd = ETHTOOL_GLINK;
-- 
2.5.0

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20160203/72a0133d/signature.sig>


More information about the samba-technical mailing list