From patchwork Fri May 17 19:29:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 10948455 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4960912 for ; Fri, 17 May 2019 19:30:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B83B2283CA for ; Fri, 17 May 2019 19:30:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD04E2843C; Fri, 17 May 2019 19:30:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D2AA283CA for ; Fri, 17 May 2019 19:30:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729026AbfEQTab (ORCPT ); Fri, 17 May 2019 15:30:31 -0400 Received: from nbd.name ([46.4.11.11]:37402 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728962AbfEQTaa (ORCPT ); Fri, 17 May 2019 15:30:30 -0400 Received: from p548c8c9f.dip0.t-ipconnect.de ([84.140.140.159] helo=bertha.fritz.box) by ds12 with esmtpa (Exim 4.89) (envelope-from ) id 1hRiYn-0006cc-65; Fri, 17 May 2019 21:30:29 +0200 From: John Crispin To: Johannes Berg Cc: linux-wireless@vger.kernel.org, John Crispin Subject: [PATCH 7/7] iw: fix fp handling inside handle_vendor Date: Fri, 17 May 2019 21:29:56 +0200 Message-Id: <20190517192956.18372-8-john@phrozen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190517192956.18372-1-john@phrozen.org> References: <20190517192956.18372-1-john@phrozen.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The fp can leak and should not be closed if we do i/o redirection. Signed-off-by: John Crispin --- 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; }