Add comment clarifying null termination

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
This commit is contained in:
Tianon Gravi 2014-02-10 15:11:17 -07:00
parent 1d3028efa3
commit 6675d69513

View file

@ -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)