From patchwork Sat Jul 25 08:18:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 1336200 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.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; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=DFYdtMc/; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=QkEL+Kgw; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BDJst21Y9z9sRN for ; Sat, 25 Jul 2020 18:20:34 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GtBI9ui1SMRuNn/Mbn//Pvv+UTDiliT1oTQFakb1Ils=; b=DFYdtMc/seNO81LlEzluf+4he pX4eoAgXaMw7KIJYZ4zw8f3LjJvrr9k1S5t4WN1YqGE9LvDSCeUlNfwcMTAJZXG6wDpO326wVsZL0 6UTycngnuF1U0Y+mOgTphVW+Rlz4OMUZ6GwtcCfUkU73G5UbW6TepLTePhULLwy7pC5t22Bsba9mR hDjKUDA+jRUmSKvSxw49LuTXESks0z35md5ijTdJQfb2FKlsELRKECybK6xfsbEhx8AWjybHFjYYz xcYWBcXSfgqKqpgs04AXJwHXRobkevJKdzqeChTTh1OMksKbW/JOCY36FbDINHclDw4qliZlFjiqC kHRc8dt8Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jzFOp-0000TB-Vm; Sat, 25 Jul 2020 08:19:20 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jzFOn-0000SZ-NV for openwrt-devel@lists.openwrt.org; Sat, 25 Jul 2020 08:19:18 +0000 Received: by mail-lj1-x242.google.com with SMTP id q6so12241299ljp.4 for ; Sat, 25 Jul 2020 01:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/3rtMxsMaROqo9059qXDWKkFQzG+IG3Ltqpzcnnr88w=; b=QkEL+KgwjYiP2I8bXUjbIUZaj+Pgl1UPTs6rXG6B8QmXlpO4usoFmHUtSvaIoMkG+b LD8B3qaANy8Q1T2CUPhJDRoqP+1RhT7637ugv9xAHBODfwfci5muX/Ur/F62GUC5aXh/ k+6zRDZFQNc0fGCOx2f9JJxkfcLuc/6DYkK08Vu4VgCBp15e79OMMeMdbUVxQNR4fD/e Ref6MdKXJMudg2zN046MvVAC9S/OpwVQAwkSW6peOpc66LBmDWmwANvnNR+jkm9DSWcX tsE4VznGoT6mGgtVEbJI/oe+kSbZYtFrbQyZhe1NzwgQaywhLE7VkTQc7pQsPlyubnKV BBHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/3rtMxsMaROqo9059qXDWKkFQzG+IG3Ltqpzcnnr88w=; b=YviW5RirCQyhJ7WJ6btSWQhiU+5t1d5w0uQULUy3DTmEiiw4o14iXhZbpKNlTOcmD6 rDHVXLerY0jZpUtW6kBWB4d2/t4q1vOHekWaYnOR/wT89ZanRrISFILiii54yG7mF3q9 N2AM/ZPlXpdmP16hLmy62FdXi7FPB9DbEAqLxRyhddsrTh0uBMjvCaeGQdTkPKezk2w0 00C8lyiq1k6zKN5jdfFhuKBWlqtK8izpQCXD1RE8O6Z8ZklqXN+S/yHyJ0LcHhET5Qjf rQa2UOOlxTNJZEkoMSEFtAzyNiJ344rt5OBrJuaxce/Z8/BjTpoGY3Xq3WrN6lzNjGB0 0DZg== X-Gm-Message-State: AOAM532m9AaAmRW6acsqiXk5+hH2RegAU10qeNe4UYhoJneNUEKGDgA0 bw5jOrlDLuTPpWyWRal9SfMF+ag4 X-Google-Smtp-Source: ABdhPJw2FJmtUa9yl4Y5tg5N7nHr4Wj7SwZlPTgP1ATU60J7WfzfoiovGpK6SK5xtFm8c9LGiVzgQQ== X-Received: by 2002:a2e:9d87:: with SMTP id c7mr5674650ljj.168.1595665155657; Sat, 25 Jul 2020 01:19:15 -0700 (PDT) Received: from localhost.localdomain (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id r14sm1071842lfe.29.2020.07.25.01.19.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jul 2020 01:19:15 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: openwrt-devel@lists.openwrt.org Subject: [PATCH uhttpd] ubus: use BLOBMSG_TYPE_UNSPEC for "params" JSON attribute Date: Sat, 25 Jul 2020 10:18:50 +0200 Message-Id: <20200725081850.32513-2-zajec5@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200725081850.32513-1-zajec5@gmail.com> References: <20200725081850.32513-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200725_041917_792031_46E4093E X-CRM114-Status: GOOD ( 10.01 ) X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.1 points) 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:242 listed in] [list.dnswl.org] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [zajec5[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [zajec5[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Jo-Philipp Wich Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Rafał Miłecki According to the JSON-RPC 2.0 specification "params" value can be either an Array or Object. This change makes parse_json_rpc() accept both. Type validation should be handled by a function that actually reads "params" depending on expected format. This doesn't change existing behaviour but allows adding more methods (that expect Object) in the future. Signed-off-by: Rafał Miłecki --- ubus.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ubus.c b/ubus.c index 51c58b5..ddc2f05 100644 --- a/ubus.c +++ b/ubus.c @@ -48,7 +48,7 @@ enum { static const struct blobmsg_policy rpc_policy[__RPC_MAX] = { [RPC_JSONRPC] = { .name = "jsonrpc", .type = BLOBMSG_TYPE_STRING }, [RPC_METHOD] = { .name = "method", .type = BLOBMSG_TYPE_STRING }, - [RPC_PARAMS] = { .name = "params", .type = BLOBMSG_TYPE_ARRAY }, + [RPC_PARAMS] = { .name = "params", .type = BLOBMSG_TYPE_UNSPEC }, [RPC_ID] = { .name = "id", .type = BLOBMSG_TYPE_UNSPEC }, }; @@ -446,6 +446,9 @@ static void parse_call_params(struct rpc_data *d) }; struct blob_attr *tb[4]; + if (!d->params || blobmsg_type(d->params) != BLOBMSG_TYPE_ARRAY) + return; + blobmsg_parse_array(data_policy, ARRAY_SIZE(data_policy), tb, blobmsg_data(d->params), blobmsg_data_len(d->params));