From patchwork Thu Jun 21 23:09:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 932994 X-Patchwork-Delegate: blogic@openwrt.org 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=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Spup6TeN"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VdrQJuSW"; 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 41Bcqt6FcFz9s4V for ; Fri, 22 Jun 2018 09:10:32 +1000 (AEST) 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ESPVvIBMfXcIQtz5YsWGzpCWxGmiFoXCTi0wee3PzFo=; b=Spup6TeN6NAQQm G9OekiGeaBYO9WAm5Pl27NxLhiK0QzsLBTHAfDNJb07RngiDzePxCS2R51YZ/s1zy3uRi1Uo3UTgE yeEImuOlsSaat7HLpQfW9NrAqG/RI04lESmvmGd8XcpHFhXjqSJ6ch1Ia1zxeOSbsJmQMsauDuOLO yizVJ6Kt7QxSVPNHyahjRl8S8kixzM0LjgGZjHsy6z2VTpNjbc6H3+/qEUMaJL/zYIR3eE1SKZrKi kRYD63VUor+qUXncCEwfVYTlokNITaXtcbwQiW62WTaWA3eYbx3Th2gRypWcr0kIpAg7ak9b7FPtL /1/3yyymOnLTK/r2KHAQ==; 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 1fW8iU-0006yx-SW; Thu, 21 Jun 2018 23:10:14 +0000 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fW8iQ-0005hN-LB for lede-dev@lists.infradead.org; Thu, 21 Jun 2018 23:10:12 +0000 Received: by mail-pf0-x241.google.com with SMTP id a11-v6so2239597pff.8 for ; Thu, 21 Jun 2018 16:09:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=QaRswk1z8GrJ+O39GKOReoR6iKlJrNi166lex8jzxrk=; b=VdrQJuSWkn91ZMI1Tw8ppJrhxw+BoYJxlsydQx02AR/1yIkbkebgOSqOZFAa6BFcpB fD0Og1zIb+gTzQmSeVooo1WBAPbIkEHChNbzitQ4fkmgDYCdA5nSs44BqaX1FVdBZDW/ Uw7BbHIEgDEI2iAG7TBLqvYbzmcHMwKOurKxdphSGbqJ1MEB+jh2i5lxkOXyKgUkvWCw rLx/wbUO9l+EH+HHyyz02kVlcs8Zp9dwZ3iLj+Z8qA0n4friOaHwtpAjm0jf+UF4i4we 87w2x/VaIjtvVvYVkAOnumA4hmTRotBwoiwKHZ4zx+yo1Ds00qv6mR/AxQhqoyVEIEZL /KtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=QaRswk1z8GrJ+O39GKOReoR6iKlJrNi166lex8jzxrk=; b=cdyeSFI2grDkBWwICFN7K+mu6GyF/olslmSsKDxCNrSsKYTLb8l5qV8D/42OD0ltqu eVTHxJU/sX8CxmPSQjHJC7GZYNTDosXXxulqscAjg/4CDi76FXDHfyXb9jOxOf2U1nd8 dx/dMRTgLFGop7M2c0lkPSfU+59lWV2vMNEXyNtQEKBeYUgu1ftNAzIDp+FxDa7GqXY/ Ikq5PY/iKSXi54RtPo3QxwwCt+0A4syvgpLW4ueSTCt+uDmHnHdr6exOIfvD7kk429z6 OGQgO4xTfBjOk1sq3MtscRxdUWNDbr8LA5nnQifHnz8YJ46PlU7GR8owuXYMr2cZH7u7 WSqg== X-Gm-Message-State: APt69E1DS160pA5FHgn+H2QCxqxYwlV64jQrYZutq15tvrTkj0/L4J7P +kDcjf5Wi02oQ3KC13UU8XE0mQGL X-Google-Smtp-Source: ADUXVKL9y79Udsvufj70eewcfM/QqjB2ZGYDpTrKBNM0zAxVJnhNQvlnGUnpTlxO783OIH8USoHAAw== X-Received: by 2002:a65:5bce:: with SMTP id o14-v6mr24113307pgr.449.1529622598648; Thu, 21 Jun 2018 16:09:58 -0700 (PDT) Received: from clevo-mangix.lan (astound-69-42-1-138.ca.astound.net. [69.42.1.138]) by smtp.gmail.com with ESMTPSA id q19-v6sm8915351pff.9.2018.06.21.16.09.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Jun 2018 16:09:57 -0700 (PDT) From: Rosen Penev To: openwrt-devel@lists.openwrt.org Date: Thu, 21 Jun 2018 16:09:56 -0700 Message-Id: <20180621230956.13613-1-rosenp@gmail.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180621_161010_724744_AF0240D5 X-CRM114-Status: GOOD ( 10.19 ) X-Spam-Score: 1.3 (+) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (1.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400e:c00:0:0:0:241 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (rosenp[at]gmail.com) 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid 1.2 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list Subject: [OpenWrt-Devel] [PATCH] firewall3: Fix GCC8 warnings by replacing sprintf with snprintf 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: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org error: ‘%u’ directive writing between 1 and 10 bytes into a region of size between 7 and 11 [-Werror=format-overflow=] sprintf(buf, "%u-%u", port->port_min, port->port_max); ^~ note: directive argument in the range [0, 2147483647] sprintf(buf, "%u-%u", port->port_min, port->port_max); ^~~~~~~ note: ‘sprintf’ output between 4 and 17 bytes into a destination of size 13 sprintf(buf, "%u-%u", port->port_min, port->port_max); Signed-off-by: Rosen Penev --- iptables.c | 8 ++++---- redirects.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/iptables.c b/iptables.c index f8d4d46..adf64c0 100644 --- a/iptables.c +++ b/iptables.c @@ -899,7 +899,7 @@ fw3_ipt_rule_sport_dport(struct fw3_ipt_rule *r, if (sp->port_min == sp->port_max) sprintf(buf, "%u", sp->port_min); else - sprintf(buf, "%u:%u", sp->port_min, sp->port_max); + snprintf(buf, sizeof(buf), "%u:%u", sp->port_min, sp->port_max); fw3_ipt_rule_addarg(r, sp->invert, "--sport", buf); } @@ -909,7 +909,7 @@ fw3_ipt_rule_sport_dport(struct fw3_ipt_rule *r, if (dp->port_min == dp->port_max) sprintf(buf, "%u", dp->port_min); else - sprintf(buf, "%u:%u", dp->port_min, dp->port_max); + snprintf(buf, sizeof(buf), "%u:%u", dp->port_min, dp->port_max); fw3_ipt_rule_addarg(r, dp->invert, "--dport", buf); } @@ -955,7 +955,7 @@ fw3_ipt_rule_icmptype(struct fw3_ipt_rule *r, struct fw3_icmptype *icmp) if (icmp->code6_min == 0 && icmp->code6_max == 0xFF) sprintf(buf, "%u", icmp->type6); else - sprintf(buf, "%u/%u", icmp->type6, icmp->code6_min); + snprintf(buf, sizeof(buf), "%u/%u", icmp->type6, icmp->code6_min); fw3_ipt_rule_addarg(r, icmp->invert, "--icmpv6-type", buf); } @@ -965,7 +965,7 @@ fw3_ipt_rule_icmptype(struct fw3_ipt_rule *r, struct fw3_icmptype *icmp) if (icmp->code_min == 0 && icmp->code_max == 0xFF) sprintf(buf, "%u", icmp->type); else - sprintf(buf, "%u/%u", icmp->type, icmp->code_min); + snprintf(buf, sizeof(buf), "%u/%u", icmp->type, icmp->code_min); fw3_ipt_rule_addarg(r, icmp->invert, "--icmp-type", buf); } diff --git a/redirects.c b/redirects.c index 7f9948c..6cd09f1 100644 --- a/redirects.c +++ b/redirects.c @@ -466,7 +466,7 @@ set_redirect(struct fw3_ipt_rule *r, struct fw3_port *port) if (port->port_min == port->port_max) sprintf(buf, "%u", port->port_min); else - sprintf(buf, "%u-%u", port->port_min, port->port_max); + snprintf(buf, sizeof(buf), "%u-%u", port->port_min, port->port_max); fw3_ipt_rule_addarg(r, false, "--to-ports", buf); }