Merge pull request #372 from JOE1994/null_terminator

add null terminator to c-string passed to 'libc::open'
v0.7.x
Dario Nieuwenhuis 2020-12-26 00:24:27 +01:00 committed by GitHub
commit 12f2e0f7e2
1 changed files with 1 additions and 1 deletions

View File

@ -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),