Removing NULL-bytes from interface name

This commit is contained in:
Dennis Schwerdel 2015-12-22 22:40:26 +01:00
parent 024442243b
commit fa4547a309
2 changed files with 7 additions and 1 deletions

View File

@ -5,6 +5,7 @@ This project follows [semantic versioning](http://semver.org).
### Unreleased
- [changed] Logging more verbosely
- [fixed] Removing NULL-bytes from interface name
### v0.4 (2015-12-22)

View File

@ -28,7 +28,12 @@ impl Device {
Type::Tap => unsafe { setup_tap_device(fd.as_raw_fd(), ifname_c.as_mut_ptr()) }
};
match res {
0 => Ok(Device{fd: fd, ifname: String::from_utf8(ifname_c).unwrap()}),
0 => {
while ifname_c.last() == Some(&0) {
ifname_c.pop();
}
Ok(Device{fd: fd, ifname: String::from_utf8(ifname_c).unwrap()})
},
_ => Err(IoError::last_os_error())
}
}