Skip to content

Commit

Permalink
Merge pull request #5 from tianon/null-terminators-are-important
Browse files Browse the repository at this point in the history
Add comment clarifying null termination
  • Loading branch information
crosbymichael committed Feb 11, 2014
2 parents f9cd1be + c626349 commit 2205707
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/netlink/netlink_linux.go
Expand Up @@ -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)

Expand Down

0 comments on commit 2205707

Please sign in to comment.