Explorar el Código

Fix a file descriptor leak in TapInterfaceDesc::interface_mtu.

whitequark hace 7 años
padre
commit
974bad1adf
Se han modificado 1 ficheros con 5 adiciones y 1 borrados
  1. 5 1
      src/phy/sys/tap_interface.rs

+ 5 - 1
src/phy/sys/tap_interface.rs

@@ -37,7 +37,11 @@ impl TapInterfaceDesc {
             lower
         };
 
-        ifreq_ioctl(lower, &mut self.ifreq, imp::SIOCGIFMTU).map(|mtu| mtu as usize)
+        let mtu = ifreq_ioctl(lower, &mut self.ifreq, imp::SIOCGIFMTU).map(|mtu| mtu as usize);
+
+        unsafe { libc::close(lower); }
+
+        mtu
     }
 
     fn wait(&mut self, ms: u32) -> io::Result<bool> {