From 6675d69513ce71e2b4acf35e008922afa132d47d Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Mon, 10 Feb 2014 15:11:17 -0700 Subject: [PATCH] Add comment clarifying null termination Docker-DCO-1.1-Signed-off-by: Andrew Page (github: tianon) --- netlink/netlink_linux.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/netlink/netlink_linux.go b/netlink/netlink_linux.go index 3b21a38..85dac51 100644 --- a/netlink/netlink_linux.go +++ b/netlink/netlink_linux.go @@ -731,6 +731,8 @@ func NetworkChangeName(iface *net.Interface, newName string) error { defer syscall.Close(fd) data := [IFNAMSIZ * 2]byte{} + // the "-1"s here are very important for ensuring we get proper null + // termination of our new C strings copy(data[:IFNAMSIZ-1], iface.Name) copy(data[IFNAMSIZ:IFNAMSIZ*2-1], newName)