aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert CH Chou <Robert_CH_Chou@acer.com.tw>2011-06-05 00:49:42 +0800
committerDmitry Shmidt <dimitrysh@google.com>2011-06-06 11:25:16 -0700
commit982de674c9fac89418509c048548471435c0c7df (patch)
tree19029d58ff2ce205284b1bed9e64d4210af3123c
parent1a441f49ec87ef74b978d7ae17da2a9b2ca6e811 (diff)
downloadiproute2-982de674c9fac89418509c048548471435c0c7df.tar.gz
fix file descriptors leaking
Change-Id: Ie76d19b279972dfd4e78bfc5fe5a302bf23de13b
-rw-r--r--ip/iproute.c1
-rw-r--r--ip/iptunnel.c2
-rw-r--r--lib/rt_names.c2
3 files changed, 5 insertions, 0 deletions
diff --git a/ip/iproute.c b/ip/iproute.c
index 711576ea..16dee80b 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -1028,6 +1028,7 @@ static int iproute_flush_cache(void)
if ((write (flush_fd, (void *)buffer, len)) < len) {
fprintf (stderr, "Cannot flush routing cache\n");
+ close(flush_fd);
return -1;
}
close(flush_fd);
diff --git a/ip/iptunnel.c b/ip/iptunnel.c
index 3525fbb2..7c682a76 100644
--- a/ip/iptunnel.c
+++ b/ip/iptunnel.c
@@ -421,6 +421,7 @@ static int do_tunnels_list(struct ip_tunnel_parm *p)
if ((ptr = strchr(buf, ':')) == NULL ||
(*ptr++ = 0, sscanf(buf, "%s", name) != 1)) {
fprintf(stderr, "Wrong format of /proc/net/dev. Sorry.\n");
+ fclose(fp);
return -1;
}
if (sscanf(ptr, "%ld%ld%ld%ld%ld%ld%ld%*d%ld%ld%ld%ld%ld%ld%ld",
@@ -459,6 +460,7 @@ static int do_tunnels_list(struct ip_tunnel_parm *p)
}
printf("\n");
}
+ fclose(fp);
return 0;
}
diff --git a/lib/rt_names.c b/lib/rt_names.c
index 52edfe33..89b1cc31 100644
--- a/lib/rt_names.c
+++ b/lib/rt_names.c
@@ -54,6 +54,7 @@ rtnl_hash_initialize(char *file, struct rtnl_hash_entry **hash, int size)
sscanf(p, "%d %s #", &id, namebuf) != 2) {
fprintf(stderr, "Database %s is corrupted at %s\n",
file, p);
+ fclose(fp);
return;
}
@@ -91,6 +92,7 @@ static void rtnl_tab_initialize(char *file, char **tab, int size)
sscanf(p, "%d %s #", &id, namebuf) != 2) {
fprintf(stderr, "Database %s is corrupted at %s\n",
file, p);
+ fclose(fp);
return;
}