diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-08-02 00:53:47 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-08-02 00:53:47 +0200 |
commit | 546ac7936340312cf272969ff83317ae4d50d2b4 (patch) | |
tree | 7ecadca11430c8624d9f80aae7c348fa4d65b969 /src/tuntap.c | |
parent | b22364f4af3564f0dd9a5f4e150bb09747bd5c4e (diff) | |
download | fastd-546ac7936340312cf272969ff83317ae4d50d2b4.tar fastd-546ac7936340312cf272969ff83317ae4d50d2b4.zip |
Introduce and use alloc helpers
These new helpers will terminate fastd on allocation failures and add some
additional convenience (allow strdup with NULL; typesafe new(type) macros).
Diffstat (limited to 'src/tuntap.c')
-rw-r--r-- | src/tuntap.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/tuntap.c b/src/tuntap.c index 7f60caf..fce0619 100644 --- a/src/tuntap.c +++ b/src/tuntap.c @@ -90,7 +90,7 @@ void fastd_tuntap_open(void) { if (ioctl(ctx.tunfd, TUNSETIFF, &ifr) < 0) exit_errno("TUNSETIFF ioctl failed"); - ctx.ifname = strndup(ifr.ifr_name, IFNAMSIZ-1); + ctx.ifname = fastd_strndup(ifr.ifr_name, IFNAMSIZ-1); int ctl_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); if (ctl_sock < 0) @@ -161,7 +161,7 @@ static void setup_tap(void) { exit_errno("TAPGIFNAME ioctl failed"); free(ctx.ifname); - ctx.ifname = strndup(ifr.ifr_name, IFNAMSIZ-1); + ctx.ifname = fastd_strndup(ifr.ifr_name, IFNAMSIZ-1); set_tap_mtu(); } @@ -199,7 +199,7 @@ void fastd_tuntap_open(void) { if ((ctx.tunfd = open(ifname, O_RDWR|O_NONBLOCK)) < 0) exit_errno("could not open tun/tap device file"); - if (!(ctx.ifname = fdevname_r(ctx.tunfd, malloc(IFNAMSIZ), IFNAMSIZ))) + if (!(ctx.ifname = fdevname_r(ctx.tunfd, fastd_alloc(IFNAMSIZ), IFNAMSIZ))) exit_errno("could not get tun/tap interface name"); switch (conf.mode) { @@ -272,7 +272,7 @@ void fastd_tuntap_open(void) { if ((ctx.tunfd = open(ifname, O_RDWR|O_NONBLOCK)) < 0) exit_errno("could not open tun device file"); - ctx.ifname = strndup(conf.ifname, IFNAMSIZ-1); + ctx.ifname = fastd_strndup(conf.ifname, IFNAMSIZ-1); switch (conf.mode) { case MODE_TAP: |