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

Add comment clarifying null termination
Upstream-commit: 2205707084c7cc5d2422a0b03e97cbf8632039d5
Component: engine
This commit is contained in:
Michael Crosby
2014-02-11 12:33:07 -05:00

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)