diff options
author | Jiri Popelka <jpopelka@redhat.com> | 2012-06-21 13:33:18 +0200 |
---|---|---|
committer | Jiri Popelka <jpopelka@redhat.com> | 2012-06-26 12:05:28 +0200 |
commit | 992a1def36ca8518f740ee8f23af1cc569ab2fef (patch) | |
tree | 8fbdb348a3d5bd088a6e4ed5c7729edf304e8881 | |
parent | 53c401782cb84978cf99113833cf9651fb8a4d67 (diff) | |
download | net-tools-992a1def36ca8518f740ee8f23af1cc569ab2fef.tar.gz net-tools-992a1def36ca8518f740ee8f23af1cc569ab2fef.tar.bz2 net-tools-992a1def36ca8518f740ee8f23af1cc569ab2fef.zip |
iptunnel.c: avoid fd leak in case of ioctl() error
-rw-r--r-- | iptunnel.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -106,6 +106,7 @@ static int do_ioctl_get_ifindex(char *dev) err = ioctl(fd, SIOCGIFINDEX, &ifr); if (err) { perror("ioctl"); + close(fd); return 0; } close(fd); @@ -123,6 +124,7 @@ static int do_ioctl_get_iftype(char *dev) err = ioctl(fd, SIOCGIFHWADDR, &ifr); if (err) { perror("ioctl"); + close(fd); return -1; } close(fd); @@ -141,6 +143,7 @@ static char * do_ioctl_get_ifname(int idx) err = ioctl(fd, SIOCGIFNAME, &ifr); if (err) { perror("ioctl"); + close(fd); return NULL; } close(fd); |