mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-10-05 13:25:53 +00:00
monitor: fix file handle leak
In some cases passing file to monitor left file open. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
parent
b27f005b27
commit
e49b51d663
@ -284,12 +284,16 @@ int do_ipmonitor(int argc, char **argv)
|
||||
}
|
||||
if (file) {
|
||||
FILE *fp;
|
||||
int err;
|
||||
|
||||
fp = fopen(file, "r");
|
||||
if (fp == NULL) {
|
||||
perror("Cannot fopen");
|
||||
exit(-1);
|
||||
}
|
||||
return rtnl_from_file(fp, accept_msg, stdout);
|
||||
err = rtnl_from_file(fp, accept_msg, stdout);
|
||||
fclose(fp);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (rtnl_open(&rth, groups) < 0)
|
||||
|
@ -411,12 +411,16 @@ int do_xfrm_monitor(int argc, char **argv)
|
||||
|
||||
if (file) {
|
||||
FILE *fp;
|
||||
int err;
|
||||
|
||||
fp = fopen(file, "r");
|
||||
if (fp == NULL) {
|
||||
perror("Cannot fopen");
|
||||
exit(-1);
|
||||
}
|
||||
return rtnl_from_file(fp, xfrm_accept_msg, (void*)stdout);
|
||||
err = rtnl_from_file(fp, xfrm_accept_msg, stdout);
|
||||
fclose(fp);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (rtnl_open_byproto(&rth, groups, NETLINK_XFRM) < 0)
|
||||
|
@ -91,13 +91,17 @@ int do_tcmonitor(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (file) {
|
||||
FILE *fp;
|
||||
fp = fopen(file, "r");
|
||||
FILE *fp = fopen(file, "r");
|
||||
int ret;
|
||||
|
||||
if (fp == NULL) {
|
||||
perror("Cannot fopen");
|
||||
exit(-1);
|
||||
}
|
||||
return rtnl_from_file(fp, accept_tcmsg, (void*)stdout);
|
||||
|
||||
ret = rtnl_from_file(fp, accept_tcmsg, stdout);
|
||||
fclose(fp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (rtnl_open(&rth, groups) < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user