Merge pull request #372 from JOE1994/null_terminator
add null terminator to c-string passed to 'libc::open'v0.7.x
commit
12f2e0f7e2
|
@ -43,7 +43,7 @@ impl AsRawFd for BpfDevice {
|
|||
fn open_device() -> io::Result<libc::c_int> {
|
||||
unsafe {
|
||||
for i in 0..256 {
|
||||
let dev = format!("/dev/bpf{}", i).as_ptr() as *const libc::c_char;
|
||||
let dev = format!("/dev/bpf{}\0", i).as_ptr() as *const libc::c_char;
|
||||
match libc::open(dev, libc::O_RDWR) {
|
||||
-1 => continue,
|
||||
fd => return Ok(fd),
|
||||
|
|
Loading…
Reference in New Issue