2019-05-17 19:37:11

by John Crispin

[permalink] [raw]
Subject: [PATCH 7/7] iw: fix fp handling inside handle_vendor

The fp can leak and should not be closed if we do i/o redirection.

Signed-off-by: John Crispin <[email protected]>
---
vendor.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/vendor.c b/vendor.c
index 860cd48..d203d85 100644
--- a/vendor.c
+++ b/vendor.c
@@ -107,7 +107,8 @@ static int handle_vendor(struct nl80211_state *state,

if (file) {
count = read_file(file, buf, sizeof(buf));
- fclose(file);
+ if (file != stdin)
+ fclose(file);
} else
count = read_hex(argc - 2, &argv[2], buf, sizeof(buf));

@@ -120,6 +121,8 @@ static int handle_vendor(struct nl80211_state *state,
return 0;

nla_put_failure:
+ if (file && file != stdin)
+ fclose(file);
return -ENOBUFS;
}

--
2.20.1