summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Popelka <jpopelka@redhat.com>2012-06-21 13:33:18 +0200
committerJiri Popelka <jpopelka@redhat.com>2012-06-26 12:05:28 +0200
commit992a1def36ca8518f740ee8f23af1cc569ab2fef (patch)
tree8fbdb348a3d5bd088a6e4ed5c7729edf304e8881
parent53c401782cb84978cf99113833cf9651fb8a4d67 (diff)
downloadnet-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.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/iptunnel.c b/iptunnel.c
index 28522fc..e89b3c5 100644
--- a/iptunnel.c
+++ b/iptunnel.c
@@ -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);