From patchwork Fri Sep 20 16:23:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Donald X-Patchwork-Id: 1987967 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=NO4Cc/S6; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=khNhXEw/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X9HnX4CGhz1y1t for ; Sat, 21 Sep 2024 02:26:08 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject: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=RPjR2x4nVsgL4SqbgSEBp8nCtsCpNSfSZlghGmXRRyY=; b=NO4Cc/S6o+kZkh 2GmbCpp2ShUyIK46TyMgCIpWaZpPyZdxRMBbYyJK27bl4q6jDsLAuCLsPGxJtE2+6pBHdOK47ezyt Z5ZsxtJURkHnKx8YhSXH8aVBq1o3eLJW3EE9SNuf23WEzbiXldL8Gt3x40ibxJ8xspm/iU9CMy7aD 8X5K4cuRhRtoWARD2VAkF5KwWgycZP83rMb2R0c2HrtXxKcFmP9LUyZ/boboUGy48m9reMT0djQTh r98ik83fYp5/D31FjUFB7NteXZ/qD/i68WuC4dPML3vjJU8+ZStB4OwlMwjNMkwNZgJ6/E+aewD8m ++SyiTbVhNnFHio8uT4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1srgQD-0000000CaWO-2G67; Fri, 20 Sep 2024 16:23:53 +0000 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1srgQA-0000000CaVx-0O4q for openwrt-devel@lists.openwrt.org; Fri, 20 Sep 2024 16:23:51 +0000 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-536536f6f8fso300273e87.1 for ; Fri, 20 Sep 2024 09:23:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726849427; x=1727454227; darn=lists.openwrt.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:sender:from:to:cc:subject:date:message-id:reply-to; bh=ZcPDk06LSJiYSwwEV8c5LnKCQAV7pomKSKVXuX8KxAo=; b=khNhXEw/e1X6deYbI5jfUpc4wIQ8/ZS0i3aycMjiGtwMMq8GMdfQkfbR7ybUv+DNYt mmXIVn9u9nxtqL5d7TDLHm56gJjUM++U3HXLhxzrjYxKtwPNRale1LtrWVaADJyrws42 gf0tiSKkiN2F4lZIZiuy2StntikwpLYDZI5DW13/GvjyQZuvicGuJVwm9FVu6nwRq5ty C0XQoxOZqeTgCe0casGGlmdcUxyXPI20duN+l6UvIHSUuq3GsM6DpDdwB8p1vSPMTwJf V3o7jCAq62CoNBKGOA9ln127cXLFZ+1+OwQnL5hgcny+sBFT6nHVYLJPuDWiwTduhSnI eOnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726849427; x=1727454227; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZcPDk06LSJiYSwwEV8c5LnKCQAV7pomKSKVXuX8KxAo=; b=mvvAD46PAqo/dLM9RrkgoS01XE/23KEBe7rqsfmAc+ZO09maZ6wo7v+gpZkMjy6wfk CpItBuaRADvSpKDNB3BzoGHYjnSxnweNlnQ4AvoMuK/S49Xl0cQwiq29A6PGv4Of8oP6 qJzZpXTkUIcQYLKjvzFclMR0rmPmw/XKOse5+drya8vj9XdTRnZmwbppUq2jECV64C23 Ne3lWKbyXOSKa0sL9shq7b2eNqfYSqZtf1VLBuaJf/xe/kxJqer3tOLK9+pwN36rOwL3 8HL6zhdw4K4fiKHA151v/MGd0sddcS8XYVZJKFpc6FMwnbEVbhf78+0kl2U9EoD2KI7j gQxA== X-Gm-Message-State: AOJu0Yzbf4NZIsIiJ/KYUZQJFm+KIbZQ7LNHqBbX1pT14yWbtDnYcAn7 o5x0OoXpcqlsSaFJLJm9Dm9D7GULfijKKohLZx6HykBHpDglAr06ZpbgKA== X-Google-Smtp-Source: AGHT+IFfsL+lVMKoQlN4cP7TT9Iegbe1sQeq8mRFVucTMk+9pR7YCWhf7Zz/hgtgFqz60r7MDqfyQg== X-Received: by 2002:a05:6512:3c81:b0:535:681d:34b6 with SMTP id 2adb3069b0e04-536ac34a610mr625939e87.10.1726849426737; Fri, 20 Sep 2024 09:23:46 -0700 (PDT) Received: from blackhol3 ([194.132.41.18]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-536870a862asm2214381e87.214.2024.09.20.09.23.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 09:23:46 -0700 (PDT) From: Paul Donald To: openwrt-devel@lists.openwrt.org Subject: [PATCH] ubox validate: port range check fix Date: Fri, 20 Sep 2024 18:23:45 +0200 Message-ID: <20240920162345.11985-1-newtwen+github@gmail.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240920_092350_155359_B71FD980 X-CRM114-Status: UNSURE ( 8.10 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The luci GUI allows a single port in a port range field. This additional check validates a single port if a range was not found. Signed-off-by: Paul Donald --- validate/validate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:12c listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [newtwen+github(at)gmail.com] X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List 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 The luci GUI allows a single port in a port range field. This additional check validates a single port if a range was not found. Signed-off-by: Paul Donald --- validate/validate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/validate/validate.c b/validate/validate.c index e72b811..ffea1d5 100644 --- a/validate/validate.c +++ b/validate/validate.c @@ -597,8 +597,10 @@ dt_type_portrange(struct dt_state *s, int nargs) n = strtoul(s->value, &e, 10); - if (e == s->value || *e != '-') - return false; + if (e == s->value || *e != '-') { + // If parsing as portrange fails, try parsing as a single port + return dt_type_port(s, nargs); + } m = strtoul(e + 1, &e, 10);