From fc38d3e86ebf2f4130e017d129487b128c8a28fe Mon Sep 17 00:00:00 2001 From: John Crispin Date: Fri, 17 May 2019 21:29:56 +0200 Subject: [PATCH] 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 Signed-off-by: Johannes Berg --- 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.39.2