Преглед изворни кода

Merge pull request #5 from tianon/null-terminators-are-important

Add comment clarifying null termination
Michael Crosby пре 11 година
родитељ
комит
2205707084
1 измењених фајлова са 2 додато и 0 уклоњено
  1. 2 0
      pkg/netlink/netlink_linux.go

+ 2 - 0
pkg/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)