mirror of https://github.com/dswd/vpncloud.git
Safety check
This commit is contained in:
parent
8bb05dd1f3
commit
7ce4c21613
|
@ -21,6 +21,7 @@ impl Device {
|
||||||
let mut ifname_string = String::with_capacity(32);
|
let mut ifname_string = String::with_capacity(32);
|
||||||
ifname_string.push_str(ifname);
|
ifname_string.push_str(ifname);
|
||||||
ifname_string.push('\0');
|
ifname_string.push('\0');
|
||||||
|
assert!(ifname_string.len() <= 32);
|
||||||
let mut ifname_c = ifname_string.into_bytes();
|
let mut ifname_c = ifname_string.into_bytes();
|
||||||
let res = match type_ {
|
let res = match type_ {
|
||||||
Type::Tun => unsafe { setup_tun_device(fd.as_raw_fd(), ifname_c.as_mut_ptr()) },
|
Type::Tun => unsafe { setup_tun_device(fd.as_raw_fd(), ifname_c.as_mut_ptr()) },
|
||||||
|
|
Loading…
Reference in New Issue