]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: fix fp handling inside handle_vendor
authorJohn Crispin <john@phrozen.org>
Fri, 17 May 2019 19:29:56 +0000 (21:29 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 24 May 2019 08:44:25 +0000 (10:44 +0200)
The fp can leak and should not be closed if we do i/o redirection.

Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
vendor.c

index 860cd48a2b7da0613d58f63b601e4ea32e55afc6..d203d8522d4fb24376b6ca86dafc8bf8d362113f 100644 (file)
--- 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;
 }