瀏覽代碼

Merge pull request #372 from JOE1994/null_terminator

add null terminator to c-string passed to 'libc::open'
Dario Nieuwenhuis 4 年之前
父節點
當前提交
9e06a04fe4
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/phy/sys/bpf.rs

+ 1 - 1
src/phy/sys/bpf.rs

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