From patchwork Wed Dec 19 11:23:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hauke Mehrtens X-Patchwork-Id: 1016000 X-Patchwork-Delegate: hauke@hauke-m.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=hauke-m.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZJYuQ3m6"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43KXZz5Cbnz9s6w for ; Wed, 19 Dec 2018 22:23:55 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=5Zrn2qA0XQPlsRMFNiJWCYRUaPQl2ssSNVchjiZuADs=; b=ZJYuQ3m62JG0zR 3mkYZqyJC9hD3Qtx8Y9w3LbFTsJyXDz2ltYTZg7dodebfyzPAIGFas91OfVw22ihiB8gqCdau2raj 6REtOZgofOy3KaYk+oSZMDogKhmoHo3OgxwR3gHZUAZBkp41DTMZ7vdDOdEBhHvMmCxpXZxbcDioB IdlxKyUC0LAaW1lnMe3dNJL5pGwcqN62RD+FGq06epqwsa/vnJ59suQf34i1Dgcc5VwxSAvURUDI2 mN9KxkiMcatK9LmJ8X9vI5GFDZHfNKogFL0Pcb1JsjafA8uq48za6QNAdY1GBxjTJGtcGnH49YNfk RzNrFSMEKxOp+BkZ9gdw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gZZx2-0006ne-HD; Wed, 19 Dec 2018 11:23:44 +0000 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gZZwz-0006m3-9n for openwrt-devel@lists.openwrt.org; Wed, 19 Dec 2018 11:23:42 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 03F8D49A61; Wed, 19 Dec 2018 12:23:30 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id 2GfzSzsQLFqx; Wed, 19 Dec 2018 12:23:27 +0100 (CET) From: Hauke Mehrtens To: openwrt-devel@lists.openwrt.org Date: Wed, 19 Dec 2018 12:23:11 +0100 Message-Id: <20181219112312.8707-1-hauke@hauke-m.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181219_032341_490486_76D92FB5 X-CRM114-Status: GOOD ( 16.10 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2001:67c:2050:104:0:1:25:1 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record Subject: [OpenWrt-Devel] [PATCH firewall3 1/2] options.c, redirects.c: Fix possible buffer overflows X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hauke Mehrtens Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This fixes two possible situations where strncpy() produces a not null terminated buffer. Coverity IDs: * 1412247 Buffer not null terminated * 1412279 Buffer not null terminated Signed-off-by: Hauke Mehrtens Acked-by: Jo-Philipp Wich --- options.c | 2 +- redirects.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/options.c b/options.c index 5184346..c763d9e 100644 --- a/options.c +++ b/options.c @@ -939,7 +939,7 @@ fw3_parse_setmatch(void *ptr, const char *val, bool is_list) return false; } - strncpy(m->name, p, sizeof(m->name)); + strncpy(m->name, p, sizeof(m->name) - 1); for (i = 0, p = strtok(NULL, " \t,"); i < 3 && p != NULL; diff --git a/redirects.c b/redirects.c index ab95395..97529ee 100644 --- a/redirects.c +++ b/redirects.c @@ -154,7 +154,7 @@ resolve_dest(struct uci_element *e, struct fw3_redirect *redir, if (!compare_addr(addr, &redir->ip_redir)) continue; - strncpy(redir->dest.name, zone->name, sizeof(redir->dest.name)); + strncpy(redir->dest.name, zone->name, sizeof(redir->dest.name) - 1); redir->dest.set = true; redir->_dest = zone; From patchwork Wed Dec 19 11:23:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hauke Mehrtens X-Patchwork-Id: 1016001 X-Patchwork-Delegate: hauke@hauke-m.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=hauke-m.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XdTCQQxR"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43KXb83B89z9s6w for ; Wed, 19 Dec 2018 22:24:04 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SVQxsieFYTG4mzBRmBGJ/iQa9EfEI0yraUZ3UiRGi2s=; b=XdTCQQxRCJYN/t W1cWNSl6WdEbS1Viim1UIUmVKuZZRME7T7mF8+jczucP/sUrSpPh6JM9x5nG7U3OHJR/X7U69wxfn Rst2c3Stb67uWB7voA1jDYFoKTeuY/edpNjEgFN9KymiOf2T0yyuDgyTMKb5yk47A2Kr9A5CxPpSs dkNtZAgAXZbMl22w39cSYfpBCgI6d4JZqRxkXZThqJ9+UARjVU+gAJuznnayJOg7VDDJZdC5AKHd6 kkaRhDuzZa7+VpPHLZH/imGxO0FpFf4c5b5GfPKfreoSmpgTPl6631VYhifuEBjo9pg2oG4RE04cq tjPOlB8E2CavzTg0Dylg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gZZxC-0006yG-6C; Wed, 19 Dec 2018 11:23:54 +0000 Received: from mx1.mailbox.org ([80.241.60.212]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gZZx1-0006mQ-9A for openwrt-devel@lists.openwrt.org; Wed, 19 Dec 2018 11:23:44 +0000 Received: from smtp1.mailbox.org (unknown [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 612B249848; Wed, 19 Dec 2018 12:23:30 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id b_itErnaJU80; Wed, 19 Dec 2018 12:23:29 +0100 (CET) From: Hauke Mehrtens To: openwrt-devel@lists.openwrt.org Date: Wed, 19 Dec 2018 12:23:12 +0100 Message-Id: <20181219112312.8707-2-hauke@hauke-m.de> In-Reply-To: <20181219112312.8707-1-hauke@hauke-m.de> References: <20181219112312.8707-1-hauke@hauke-m.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181219_032343_467521_B5B44D73 X-CRM114-Status: GOOD ( 14.36 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [80.241.60.212 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record Subject: [OpenWrt-Devel] [PATCH firewall3 2/2] utils: Free args in __fw3_command_pipe() X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hauke Mehrtens Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org args was not freed after leaving this function. Fixes Coverity issue 1412470 Resource leak Signed-off-by: Hauke Mehrtens Acked-by: Jo-Philipp Wich --- utils.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils.c b/utils.c index 4f892a7..684b2c3 100644 --- a/utils.c +++ b/utils.c @@ -252,6 +252,7 @@ __fw3_command_pipe(bool silent, const char *command, ...) switch ((pid = fork())) { case -1: + free(args); return false; case 0: @@ -275,6 +276,7 @@ __fw3_command_pipe(bool silent, const char *command, ...) } pipe_fd = fdopen(pfds[1], "w"); + free(args); return true; }