From: John Crispin Date: Fri, 17 May 2019 19:29:56 +0000 (+0200) Subject: iw: fix fp handling inside handle_vendor X-Git-Tag: v5.3~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc38d3e86ebf2f4130e017d129487b128c8a28fe;p=thirdparty%2Fiw.git 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 --- 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; }