From patchwork Mon Oct 21 06:10:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yousong Zhou X-Patchwork-Id: 1180338 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=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="ULG/vLYG"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="K9PwKdxj"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 46xRMr25KGz9sPL for ; Mon, 21 Oct 2019 17:20:40 +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=FoIv59Ogd+5Ab82bggDBnz/nENGjbasYsHkaZq7taVw=; b=ULG/vLYGEkP7QB YTabviHXhkyapq7df9tvDyx/cSR4GPq/7rYzQQtDSEx0EsQUK7xMSRVlnDdPb4R2g7zBdG/Lqj2cx WFy0iKS7q+SEqD0ZMthCZ8ipBE2aqGs/4rzadpUtiWvmVt2xNiPFWQvitCILf6vlw2rdXyQ8T9lyL pG7Z4IyF68V5piu6UEVnNREJ9AN0w/9nlBBCvIO1qZgtlYQXSroTkEbrvOvZ8T5F2DNnqPOiyjgzr esdl7JHfkPkvUtyu7YZ4oZNrsn93MfckhPEQq2VyLN0HlEfdehS8EJwfexsf7pfAL7b60oChQNNGU kWCXWeQu0aN8TpUOxq2Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMR3U-0003Qg-8q; Mon, 21 Oct 2019 06:20:36 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMR2x-0001e8-Jh for openwrt-devel@lists.openwrt.org; Mon, 21 Oct 2019 06:20:08 +0000 Received: by mail-pf1-x444.google.com with SMTP id q5so7719906pfg.13 for ; Sun, 20 Oct 2019 23:20:01 -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=yIfx7x5q6VfO1k3FG+/WbYdOYm+zMB3yC9Sw9uNW/Ic=; b=K9PwKdxj+jF4sP9XKPsOsNEFBVizk+oozcRG7yCKzf2RZvMUglDpOOD/hMjvFZ0/zM RHMk7m2vOZ2pjs1pZ/9l80ocNlgYSdeTdbNzwUTbs4JSA6DEDeLsz6TPoWcjGfmfA4ql jqvJSEB89Dk/In5bFGLGmyO3K7IzFgrvlgCOce5E4ZPTFp1FKJV9ybZ1JClSIVR0IyNc ufGKhdfMR11J6j12TKLRJS2RKxA8kUu3l7uUDLEACiNJhd1e3//5ijpRe/Chzop6/d5k u52gLMkwoA647JQthymY6oKHnuZDZJldxISS4LtmCnYyfGGUt9UY0pUgOW0EaLIqVCim sG3g== 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=yIfx7x5q6VfO1k3FG+/WbYdOYm+zMB3yC9Sw9uNW/Ic=; b=Y2apK/vRZct0uy1ByBUgr/Qb09NfaVo/F+TJ29D2hapMNL0JmUyaJbgMEfww+wYTva mpnb848gOkWM89CxfZ2TYH/r++WrxcdfRuwqC647ZeuAX/eYntM2GDAck97PyZrSQNjT smyrGeqAmCyjDi5ODKsEL2SaKgFuYxU/0sjANvmjGCpeFQTgFgknnKLoo6d2rZMn6oIJ Z7dlK8d9/S+ENqaN975p+YwvmQ1VXtq3ERS0stjmAP4yvO/FPZO0zf0sXumIPd2EgGmA FVnt6x7k+hVezoGrIgQKsByeUMpYs2JhwQWG7zla3RffcgOr5RTx6WeCdVcGeO1W8HzK vraA== X-Gm-Message-State: APjAAAV9ZTnNkyK9KSc5cuejvIegad9q7x3mGC5nB8/i6U7so4iiN84q t6yC0nhSe+fhepFtRH3MFpI= X-Google-Smtp-Source: APXvYqxVHh1BYaCjd7rgpj1q3JRT1P2yX7yxRa8Zg9DJoDXTFDKWbqqQNOjhwvDjSeBJ76Ua8G6FkQ== X-Received: by 2002:a17:90a:8c02:: with SMTP id a2mr26702275pjo.79.1571638800776; Sun, 20 Oct 2019 23:20:00 -0700 (PDT) Received: from titan.hq.cloud.yunionyun.com ([47.244.19.249]) by smtp.gmail.com with ESMTPSA id b22sm13524784pfo.85.2019.10.20.23.19.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Oct 2019 23:19:59 -0700 (PDT) From: Yousong Zhou To: jo@mein.io Date: Mon, 21 Oct 2019 06:10:26 +0000 Message-Id: <20191021061031.81230-2-yszhou4tech@gmail.com> In-Reply-To: <20191021061031.81230-1-yszhou4tech@gmail.com> References: <20191021061031.81230-1-yszhou4tech@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191020_232004_222835_5448EB41 X-CRM114-Status: UNSURE ( 8.85 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:444 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (yszhou4tech[at]gmail.com) -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 Subject: [OpenWrt-Devel] [PATCH rpcd v2 1/6] plugin: exec: properly free memory on parse error X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yousong Zhou , ynezz@true.cz, openwrt-devel@lists.openwrt.org Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Signed-off-by: Yousong Zhou --- plugin.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugin.c b/plugin.c index 3740622..d3526aa 100644 --- a/plugin.c +++ b/plugin.c @@ -321,11 +321,16 @@ rpc_plugin_parse_exec(const char *name, int fd) obj_type = calloc(1, sizeof(*obj_type)); - if (!obj_type) + if (!obj_type) { + free(obj); return NULL; + } - if (asprintf((char **)&obj_type->name, "luci-rpc-plugin-%s", name) < 0) + if (asprintf((char **)&obj_type->name, "luci-rpc-plugin-%s", name) < 0) { + free(obj); + free(obj_type); return NULL; + } obj_type->methods = methods; obj_type->n_methods = n_method; From patchwork Mon Oct 21 06:10:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yousong Zhou X-Patchwork-Id: 1180337 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=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="iJxYL7lc"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CVrUlbu9"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 46xRMr1M42z9sCJ for ; Mon, 21 Oct 2019 17:20:40 +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=abZa8+XJUfQnUeMNtMZUnK9Ey5TdVWbvObp/ciU03EY=; b=iJxYL7lcKRgb/u pkhuifZfoAph1LcxMI2+fTJArM1els3JPdztPMHRs1ZyhyTI3dXzrAOa0mTqbOPUcAhlcdZ5ZYDTe aeEe6b4YxlnZI7mqnYB5cKWEHg5dBKfQnHrx/07+BqPhN6Ndp7Vc2/qTaerX72y5DE3WBj/HUA5by NaNlpcz7d4cl19qt+BYGfYUPAd3QTbR+jDnR4JcuTiFvm9jZEOpMurR7TUeZjUt0bRt5WEZ9BnA9r RPEsIIEeqI+jNISpX/j76EjMqA6jqdkrtoxyoCWaaXEYJrxsGt+s+3P6N/HXTo6UUhUWoki46sTVD I0T/wmixzJ2d6rSbSEyg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMR3J-0003Bo-6e; Mon, 21 Oct 2019 06:20:25 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMR2z-0001lh-TJ for openwrt-devel@lists.openwrt.org; Mon, 21 Oct 2019 06:20:08 +0000 Received: by mail-pg1-x543.google.com with SMTP id 15so1760204pgt.7 for ; Sun, 20 Oct 2019 23:20:04 -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=dewVCS/7JBbxKksE2Vov+3TUCQAWtJOnNFVCaWe2Me0=; b=CVrUlbu9MH8o9yMxbkGAFvf8QzZNGLuQmPpopSDhKVHRNOFzgajoac2lpyk0j1HsQY GYUXGnDpwNEzahdW3OIGQ0pWO5qSYjeLw1O6rb+W+IDi1Kz47+twUreWADNNayKT/Uz0 jHknUWWtJwKI5zPwzZglMUQqfCGl4NtyY80HBfg1sFf4tdQrffMRJ+HF+4ecybNAyFp7 qaXABiY9tatSoqMJeXGV/qU5cNQ7UlHBsLv1MM1TCZF3L1LMncDUya0tS2etyf8Ua74l YfNcntcu2ZX4mSDXqYkgCJhq6RK8jO5jpizQujNZVaVF/GFHnGJ2vXbceAFZy5sH3ImM oWaA== 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=dewVCS/7JBbxKksE2Vov+3TUCQAWtJOnNFVCaWe2Me0=; b=qUNS9w54KDH5YcIU84Qk9a94hetQY9/hrIFG1zt0flj4quJijtmstG110bZIT/j/ds HrT1iwJsRAF5gCRQbWedi83pULpOlwON9wWaCyf+oYE7IhAGJ7ygKnJE9jwphOczFyOn QT9WcaWY1goJHEJps4iPv03PZjPzBGO92+Hr7UBOqYRNcFvuHr2SEhveWKn4F7SzSrFR FrCEDcyAXZu4fjWi6BzYep1xUmS9jgsA6CxJ+SVc1vui+xLQT4s7i2EbGwL88lwyIWGT Do0NMSdjbilFzZXgAJXhZC9os9vuqL0FeRFyxSCqIt8Js4i6m2EBFp+so3Cy1aDWhEUk rRaQ== X-Gm-Message-State: APjAAAWsnn8KBIInc0bd2Rl9yTTUBTPAxUSglGjM/Yq2gLIt51UgSMeH dG73aZTyTeeNw0EDyRt6hBsDz1AJPlI= X-Google-Smtp-Source: APXvYqysuZU/zGV0M83+qcYZDTtWU276rZSykEEaPjFpRNdYRfj/iHJAureABuYNbwgUxD1O+0CzJw== X-Received: by 2002:a17:90a:de02:: with SMTP id m2mr26757185pjv.21.1571638803255; Sun, 20 Oct 2019 23:20:03 -0700 (PDT) Received: from titan.hq.cloud.yunionyun.com ([47.244.19.249]) by smtp.gmail.com with ESMTPSA id b22sm13524784pfo.85.2019.10.20.23.20.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Oct 2019 23:20:02 -0700 (PDT) From: Yousong Zhou To: jo@mein.io Date: Mon, 21 Oct 2019 06:10:27 +0000 Message-Id: <20191021061031.81230-3-yszhou4tech@gmail.com> In-Reply-To: <20191021061031.81230-1-yszhou4tech@gmail.com> References: <20191021061031.81230-1-yszhou4tech@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191020_232006_133247_0288F395 X-CRM114-Status: UNSURE ( 9.36 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:543 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (yszhou4tech[at]gmail.com) -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 Subject: [OpenWrt-Devel] [PATCH rpcd v2 2/6] exec: properly free memory on rpc_exec() error X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yousong Zhou , ynezz@true.cz, openwrt-devel@lists.openwrt.org Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Signed-off-by: Yousong Zhou --- exec.c | 7 ++++++- plugin.c | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index eb52966..f490ad7 100644 --- a/exec.c +++ b/exec.c @@ -313,7 +313,7 @@ rpc_exec(const char **args, rpc_exec_write_cb_t in, switch ((pid = fork())) { case -1: - return rpc_errno_status(); + goto fail_fork; case 0: uloop_done(); @@ -372,6 +372,10 @@ rpc_exec(const char **args, rpc_exec_write_cb_t in, return UBUS_STATUS_OK; +fail_fork: + close(epipe[0]); + close(epipe[1]); + fail_epipe: close(opipe[0]); close(opipe[1]); @@ -381,5 +385,6 @@ fail_opipe: close(ipipe[1]); fail_ipipe: + free(c); return rpc_errno_status(); } diff --git a/plugin.c b/plugin.c index d3526aa..ac8de6d 100644 --- a/plugin.c +++ b/plugin.c @@ -161,9 +161,11 @@ rpc_plugin_call(struct ubus_context *ctx, struct ubus_object *obj, c->argv[1] = "call"; c->argv[2] = c->method; - return rpc_exec(c->argv, rpc_plugin_call_stdin_cb, + rv = rpc_exec(c->argv, rpc_plugin_call_stdin_cb, rpc_plugin_call_stdout_cb, rpc_plugin_call_stderr_cb, rpc_plugin_call_finish_cb, c, ctx, req); + if (rv == UBUS_STATUS_OK) + return rv; fail: if (c) From patchwork Mon Oct 21 06:10:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yousong Zhou X-Patchwork-Id: 1180339 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=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="m2qsZjZA"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ndPIFLNZ"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 46xRNL6H07z9sP3 for ; Mon, 21 Oct 2019 17:21:06 +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=Ql7T8TC11dPkjTDSgd+7wkdDfF9DEB6Asr1M6qbtxv0=; b=m2qsZjZAnIZIlK nfxLq+Tlx7R0NatAHeWtjFwaHaA9H7Y1TEf8ieNjKHeOCQjVCz9Ix8qmigzVVXOXWJfWIBYEkSxjs nZHQPzEOXa0r/dWFpr/Bm3AEl2j95ThmMWi0U1ojr9gtpQhNL9RKZMQnIT7Hz4Fm09JnA63s2kqk4 553MpaBlOdgOsCC2goCdnQ/6P9lxbotWg0fL0so5cqhL454eFMRlIyRDtom56L2bA9GwqiwhJd+4d A/jYvUgc3BrbulmsqV+q6jZ7lPk5gyqo8lZcNTBuEu/YvDzuh8PI8sfrpyKB/EHWBRbdehm0rw/5a VOewo3syxt/Zvs1/pfWg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMR3m-0003p7-BF; Mon, 21 Oct 2019 06:20:54 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMR32-00025o-DF for openwrt-devel@lists.openwrt.org; Mon, 21 Oct 2019 06:20:10 +0000 Received: by mail-pg1-x543.google.com with SMTP id c8so2300393pgb.2 for ; Sun, 20 Oct 2019 23:20:07 -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=ejY+PPDeC6zoFnTQsHsb6CWTJLNp3GAskceRPkj6Yh4=; b=ndPIFLNZsZzo+12jhDWsC1NvTnDQDCuExWlcWFamJfJ4gmp2gbQIAgF6oIFlyZItCK 6r+tlY5VnIywK3ML6RJ6AiiHz12aW36ZX7zRWSREkS4aif1numYRtD/EpjECSWw9EZJ+ eA3bME+1bxVt9igdueN6CyD7h30aPsdAjq1qZRN6gsu0/w44Zq78EI9S9aQ0NOqEawwr /SUO69l5BtPE9d7Iek8rGSLT7zAQZ3Pj2zjEma/pzaA+FZPD3fburCSeq+TAEm9Yl1ME mLODTXC5BPWE+Pltiw+oerjYGCiI/yUXa5yAScZ+/aOwlqFllD1ds2E648XgSw+SmYrc gLCg== 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=ejY+PPDeC6zoFnTQsHsb6CWTJLNp3GAskceRPkj6Yh4=; b=XGCTGcdHhsqT6zJ2OaxXqGAcux4Iage8nDO6qXPpcHQS0tRpAyC0TPMDU5zxhiKGmc bPwmBhmYWGhowH1wIRvsGT1FcGRTFX/SSplstADte2eoNI2VNxhvRyeW5mlrPGUBlNlL 77KMHZ+W/rWthelNSu3rQ6g49MxAWGj8PGHPRL7hGoy4lzmidXWsh/RrxMVPX+KSLdfP YdsmSTrgAkzSdcL/RjmmdKsBZvpEVDc9inXW+5WDooUq6GNHpeULB0sUDIMHu/jbzGal p/J6UWeZ9MtG4p75jUFdqtRYZ7SzqAqQsUIE+/kvWm3a6bqYi3xyJXl6jZQFRY3DbsfW rdxA== X-Gm-Message-State: APjAAAX0o5nHtDTZ+e4Pb4Cm024Pe5F2+uLx0u4GoRJdSsW1OVqoMTMY RQnt09rg5ueGVmTlnq6fQkI= X-Google-Smtp-Source: APXvYqzQdyRbknJRahgm19QeOpPvEeSTBMZIagXAytocz8NQcjYliJ1ysDuoaYKo/XSQ2UTNmlOLQw== X-Received: by 2002:a62:a504:: with SMTP id v4mr20340079pfm.243.1571638805812; Sun, 20 Oct 2019 23:20:05 -0700 (PDT) Received: from titan.hq.cloud.yunionyun.com ([47.244.19.249]) by smtp.gmail.com with ESMTPSA id b22sm13524784pfo.85.2019.10.20.23.20.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Oct 2019 23:20:04 -0700 (PDT) From: Yousong Zhou To: jo@mein.io Date: Mon, 21 Oct 2019 06:10:28 +0000 Message-Id: <20191021061031.81230-4-yszhou4tech@gmail.com> In-Reply-To: <20191021061031.81230-1-yszhou4tech@gmail.com> References: <20191021061031.81230-1-yszhou4tech@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191020_232008_787704_8EB74258 X-CRM114-Status: UNSURE ( 8.72 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:543 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (yszhou4tech[at]gmail.com) -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 Subject: [OpenWrt-Devel] [PATCH rpcd v2 3/6] exec: alway call finish_cb to allow plugin to free up memory X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yousong Zhou , ynezz@true.cz, openwrt-devel@lists.openwrt.org Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Signed-off-by: Yousong Zhou --- exec.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/exec.c b/exec.c index f490ad7..1b05a91 100644 --- a/exec.c +++ b/exec.c @@ -131,13 +131,12 @@ rpc_exec_reply(struct rpc_exec_context *c, int rv) rpc_ustream_to_blobmsg(&c->blob, &c->opipe.stream, "stdout"); rpc_ustream_to_blobmsg(&c->blob, &c->epipe.stream, "stderr"); } - - if (c->finish_cb) - rv = c->finish_cb(&c->blob, c->stat, c->priv); - - if (rv == UBUS_STATUS_OK) - ubus_send_reply(c->context, &c->request, c->blob.head); } + if (c->finish_cb) + rv = c->finish_cb(&c->blob, c->stat, c->priv); + + if (rv == UBUS_STATUS_OK) + ubus_send_reply(c->context, &c->request, c->blob.head); ubus_complete_deferred_request(c->context, &c->request, rv); From patchwork Mon Oct 21 06:10:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yousong Zhou X-Patchwork-Id: 1180340 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=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="VRJE21kA"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JjDFDKyK"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 46xRNR5Vnjz9sP3 for ; Mon, 21 Oct 2019 17:21:11 +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=dBG0RxFr5kdsaYc5CVQCP92HMIkrkpVOs7BhNNolpew=; b=VRJE21kAjdGyQS IVmRPHlDtyJU1Oe+G9LQdtP+lZ0cIe7Sw40UnIb/YNVsD6BIQ13VsJ93D9SXP7Kb2AaufvIGmvFpr UJodZScOyh82GzXbVqIuEjerPQjN0mdRwwoxrisKYtAtthYnPK+W1l8dsDbp5dZF0qteebR5LU9XY Sqy39PYzgz9jKsnGkLVxU3KP0eNeOKYgFfizB1hgOcFJMXIzBScXqxYjEw9BoAeYKITasY5d81P1W cLkeFmfZkt/n47LsJZsNQzwxozTFDS+NOzYI7tchQR7VZly2Uevq4vdahgQYBbwCHujf+rFXxtNEr rA3IbeQwLoaGh+9xRjqQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMR40-0004Ai-14; Mon, 21 Oct 2019 06:21:08 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMR34-0002O6-U6 for openwrt-devel@lists.openwrt.org; Mon, 21 Oct 2019 06:20:12 +0000 Received: by mail-pl1-x642.google.com with SMTP id w8so6102040plq.5 for ; Sun, 20 Oct 2019 23:20:09 -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=Y+cd/mTDc3lc5WzC6mmSoTRtAxA7VUtk54DyNACU7r4=; b=JjDFDKyK98cW3r/50LWNZ6yZRVWJTOJ7s4lihS2gAbhSSYdjEkcOZq75bi4Aup0BOx o2XdW1SSeNcdF0c/+8/Su9Yo/1KycacOwuqn4uyIXdTO9YWegfEbJ7FW+7ZncBNqPMVM fKzn0cgMBj+59ZDEyG77PmaNTZPdf/aNE0/ByzdBXF0aNDQYkV9zCSbnvJF3JKsHL+re DA6zEopz8n1DlN1k6GLcNJK3DTmXFcs+dZSXBwfkldc1iU12uHNnERC03ooEbUjEEX3k HNa6rr+lySz/G3ksM29ekpU/kX9ItT/tCumSl+DtFDzDbIMJt5Mx3WM4pMrSLOjkSRoq 2sYw== 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=Y+cd/mTDc3lc5WzC6mmSoTRtAxA7VUtk54DyNACU7r4=; b=IFxdug9RRjfQ7GdG0XP5tpIBBb0X6eJz+H6yUWy2fteLUI0fUploBLgIFxyHmetDhx 5cCW8qnichkhCVutPj9Bg+4wq5nveLc+2s9Cc2Q60szZBdk8G5yYgV/SBRnfXWj/51uw q1mQNqNZvMP9LQB2L/gXrCuPAZgCey3mBvYVMlmbsxFxYWIUwJHVHC2WKN0sJeOiEiZ0 gI/PyHd8BkDD2NRhdEvMxs9hYrqWLkQwZm97mNpYa7a099o83BPiGSY9DVZajoM14zkX XTK+T0c1xytSTMmM4dRXXbte5aND+qePfBx1Qh6QIOoJ/lA67pNi/YiIiq/sZm4sP5K1 6img== X-Gm-Message-State: APjAAAWQ8Km96Hxw6NgJ3Xp1Y78DhfGyeDU3MzkuFNQ00b+G/dKqjXg9 xPV5TCWLmua+Gn4Wb3yKr6NjAvXMmFY= X-Google-Smtp-Source: APXvYqzU1q7zCs19tQIxxBO5gT98o7j+daqRzUT8jkTX47QAA2SiV0CPVfEWzpcyi1+NqBySph4rSw== X-Received: by 2002:a17:902:a712:: with SMTP id w18mr23246245plq.304.1571638808472; Sun, 20 Oct 2019 23:20:08 -0700 (PDT) Received: from titan.hq.cloud.yunionyun.com ([47.244.19.249]) by smtp.gmail.com with ESMTPSA id b22sm13524784pfo.85.2019.10.20.23.20.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Oct 2019 23:20:07 -0700 (PDT) From: Yousong Zhou To: jo@mein.io Date: Mon, 21 Oct 2019 06:10:29 +0000 Message-Id: <20191021061031.81230-5-yszhou4tech@gmail.com> In-Reply-To: <20191021061031.81230-1-yszhou4tech@gmail.com> References: <20191021061031.81230-1-yszhou4tech@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191020_232011_096292_39928719 X-CRM114-Status: UNSURE ( 7.84 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:642 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (yszhou4tech[at]gmail.com) -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 Subject: [OpenWrt-Devel] [PATCH rpcd v2 4/6] uci: free configs list memory on return X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yousong Zhou , ynezz@true.cz, openwrt-devel@lists.openwrt.org Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Signed-off-by: Yousong Zhou --- uci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/uci.c b/uci.c index 1587a19..7667505 100644 --- a/uci.c +++ b/uci.c @@ -1284,6 +1284,7 @@ rpc_uci_changes(struct ubus_context *ctx, struct ubus_object *obj, uci_unload(cursor, p); } + free(configs); blobmsg_close_table(&buf, c); @@ -1388,6 +1389,7 @@ rpc_uci_configs(struct ubus_context *ctx, struct ubus_object *obj, for (i = 0; configs[i]; i++) blobmsg_add_string(&buf, NULL, configs[i]); + free(configs); blobmsg_close_array(&buf, c); From patchwork Mon Oct 21 12:59:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yousong Zhou X-Patchwork-Id: 1180573 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=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="pD7s+a80"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GhPt+99k"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 46xcDX3CWwz9s4Y for ; Mon, 21 Oct 2019 23:59:56 +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=jKrItd23Wsl85FwGdc7DlMCKPRTIH/VWpQFD4cYssrg=; b=pD7s+a80HDY5EK xFbn4X609D6kWM4xVyaO6ikTZKn2G7RI5A6k7WP69O8R9Fwrq40RDpxExNjTPUISVUGt2hn+KWooK E3qfap7ZUSN58NiZg6GB+LbG0A49FXfRbTZXC7bf1+us4UHcs3J9ZBVxrJbdd0dmtDGJ2hFDLHjP/ /zqzXYIswD8r/Ttgvvj73AgINap9BmZwDAW8FfbfGuGHUYEV9+cqMBcvOJYasc/2fe3YwocPoCWlM VvacRt9pLArClPtXdxgGE/yONxSu0KZpHkAQI1yS3NK1iR5Mj9QAnvsmNYmlotLhAK/hXanGRJaiQ CoCecFwotwz8V5VKSoBA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMXHl-0003Bj-2V; Mon, 21 Oct 2019 12:59:45 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMXHi-0003B0-Gf for openwrt-devel@lists.openwrt.org; Mon, 21 Oct 2019 12:59:43 +0000 Received: by mail-pg1-x544.google.com with SMTP id p1so7790709pgi.4 for ; Mon, 21 Oct 2019 05:59:42 -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=Q9hdKeZbSFvbKqGiUnL/KlVn+J1eBFMLqvPvJIrTN9I=; b=GhPt+99kkK30jjTpJGInn3P1gg42eZOa8l+6+uxLJVfnTUkDrWGLV0kpoLcULIpr8g iPDARMmAX4zdb2f+0gzR2z5TIllsPxxXmDcHf7Ib6T2TX6/me0XHIMVxvAnDOB/3kdCI MnFp+5aYXLQsrJrOqrL0iflOSp3bb+Wve/a/flDkho0IBgHBgltLFoe527jyZLkleCQH u0qGN37qg4cz98C6UqyLXpzjpqiS2Wbi2fqZYkAzInKuVKvyEZcYw0Vov5N0ftF+ud+B 0/dR7pvyclna73ms49mOpMXi5p9XoqcxpnkdPSiy9ICYkmWOwcXcKB5ywC8QSKGx35t2 ZKKQ== 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=Q9hdKeZbSFvbKqGiUnL/KlVn+J1eBFMLqvPvJIrTN9I=; b=bVHdX6gCk3GHO0dvo6YBiMMqkQt32fo+SqLC/poN5FEKoGbE2NH8rS0WzKsRsvzWja TMb2VjozREMzeqTFsyB6G1ahkbrYSVYGO2pT2sfQuV+YiVMW0YzbOgmjctNxB1Mw2f4Z wiVYz+c2vDooD3hU/GFdRIUylj6+5o5deQ9uD+0jBEIHsF8KtY7qfHM3sMPD/CXgxPyM kP+puqx3LAeUjDl3kW2GnhguUhHm8sMitdz212mJ6ws34fOSROyx9iSl9w0Xr8mjdiYU A+eKZ1pHDj7dCTho3RLDNhhLDquSUCOmwcBuUHImqFPegrQb9MwdmPhQPdtpMVDelKM1 LBHw== X-Gm-Message-State: APjAAAXfs4S4Ut8oG8icRsNwVbVnwzoUyVKm9vOWTKatATMfKcKiAbdy uf8kxM3UuQzmnjB+2bnUA0c= X-Google-Smtp-Source: APXvYqw5fAu5aAd2OhqUWkZ19+Ps5wkOqJUjdkkzaDkNTW9AHZv6o+GyE2ptfSfNLs2V7RfZjJCmhg== X-Received: by 2002:a17:90a:c382:: with SMTP id h2mr27791806pjt.110.1571662781409; Mon, 21 Oct 2019 05:59:41 -0700 (PDT) Received: from titan.hq.cloud.yunionyun.com ([161.117.5.46]) by smtp.gmail.com with ESMTPSA id 20sm15880813pfp.153.2019.10.21.05.59.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Oct 2019 05:59:40 -0700 (PDT) From: Yousong Zhou To: jo@mein.io Date: Mon, 21 Oct 2019 12:59:23 +0000 Message-Id: <20191021125924.37223-1-yszhou4tech@gmail.com> In-Reply-To: <20191021061031.81230-1-yszhou4tech@gmail.com> References: <20191021061031.81230-1-yszhou4tech@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191021_055942_571225_D939B56D X-CRM114-Status: UNSURE ( 9.34 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:544 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (yszhou4tech[at]gmail.com) -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_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 -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain Subject: [OpenWrt-Devel] [PATCH rpcd v2 5/6] file: exec: properly free memory on error X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yousong Zhou , ynezz@true.cz, openwrt-devel@lists.openwrt.org Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Signed-off-by: Yousong Zhou --- file.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/file.c b/file.c index b1adcb7..47fcd9a 100644 --- a/file.c +++ b/file.c @@ -823,13 +823,15 @@ rpc_file_exec_run(const char *cmd, const struct blob_attr *sid, if (!c) return UBUS_STATUS_UNKNOWN_ERROR; - if (pipe(opipe) || pipe(epipe)) - return rpc_errno_status(); + if (pipe(opipe)) + goto fail_opipe; + if (pipe(epipe)) + goto fail_epipe; switch ((pid = fork())) { case -1: - return rpc_errno_status(); + goto fail_fork; case 0: uloop_done(); @@ -921,6 +923,16 @@ rpc_file_exec_run(const char *cmd, const struct blob_attr *sid, } return UBUS_STATUS_OK; + +fail_fork: + close(epipe[0]); + close(epipe[1]); +fail_epipe: + close(opipe[0]); + close(opipe[1]); +fail_opipe: + free(c); + return rpc_errno_status(); } static int From patchwork Mon Oct 21 12:59:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yousong Zhou X-Patchwork-Id: 1180574 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=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="VXfN620d"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PZAaaZPH"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 46xcDs5FHHz9s4Y for ; Tue, 22 Oct 2019 00:00:13 +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=sHNqpEqj7ZB8nUMIYX7uE3bmlVaAIz9KNGJPsb5N9DE=; b=VXfN620dsODeqj mG5mZj5I0xLwh0eS1KqSYF6K6RGyE1Vfg7GYP8csyusf2FsDOB8Z5owdDfiHxcn7wHrfMrm9DX/5r 8UQ+pgDcMtWmg1exFOmHyImcJ0Qb3ZQPbooaxEhwxWNNIlqnJD1l7Tl6j7ASgQSdp/pQ6QfEwdGE4 GJ5vetz6812zk7N6nJAMAa7NeV+XX12js104bytpScSjsUsT16QiTAHtQpLezomkGNV/S3wBGv4fc d8Bj58gwRUOFdC4ooBoH64e6u89zYu9+g/y05OrQeDW+jxK/PCu2b1YGrWYwzbytEj/EjU+eZBYpv NY90mwIC2SCjAReP9isg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMXI5-0003oe-MB; Mon, 21 Oct 2019 13:00:05 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iMXI0-0003RI-U3 for openwrt-devel@lists.openwrt.org; Mon, 21 Oct 2019 13:00:02 +0000 Received: by mail-pf1-x442.google.com with SMTP id a2so8390549pfo.10 for ; Mon, 21 Oct 2019 06:00:00 -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=W6hg5DzKfbUUZ45XfZCgQZ7FjvjJEZSIJo0bMLSzhyU=; b=PZAaaZPHE6ZiJMksn9Jh45IWnb30m3NgGdC4W1lb+u/gPWLdEWkPA1zTnrA9YKyPi7 KFsSQPc/T+hcmTjMyRrLpijFbPtLnkjpn9VLHcqN8D2jw6QmimxDheajM8lp6wWieeNq uYFqGJkiww1CjnD2k9O9HKqd1FkkRdZA/UrtAym3VsfNeBRda+RIwrrB+tiWBmGXP2D5 9M5lHDAZq4iZvWiBHEBTw5EeFjLxWojRzkb7kNBR21KkNIN3QYcnd58jl6Za3UfY0Z8U GaAWCgiPEwOMfgJgXE5JaFmuHZ1hc3eyKDD8lhn6L5J8tKiuQYH/HXIjeUitnERNaGta gF0w== 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=W6hg5DzKfbUUZ45XfZCgQZ7FjvjJEZSIJo0bMLSzhyU=; b=RSc4e3LEzvCi4DeUh/nlOELwxXZ477cmZp4x1DZZgyKTddTzp4Omwqh4czEXtGs/6j N3SLyJuMNWNZIgVp6UxkeR74l15OM3jRmtqEg19Ya9cYRSS2t62t8vlHDjhHk15FKpOn XJgq5gVzoex3lGOxnbjcBZ0PTT05LxTNvwmEoe+F8WdME5C3g2IS9JSwUyNBqwT1ZY3l pCullN2tacaocoEHHOW5jUEmj87VforKsCQAvziokt/ZxvHXVbsgWAKRJI3zdYT+9NyU oXGL8SE5o2F3PacR8AGTFNuvjzky7JGMAEGB2NG2nZv6GIEzVukCgEPhe4qNvptrBFql yYTQ== X-Gm-Message-State: APjAAAXhWevmx/0gzs033c6NUl0vcZIyYzSEi4OouvgtApVHpDtUbDqL 8szaGkSMx35Dnlpcoh8B+YE= X-Google-Smtp-Source: APXvYqz2kqN6a1BfQt82ZKnEC5aHS2Vg9YUwDQeinkKKcRkcDHbAkp1cKQHppstvKXASEcDUQgsSEA== X-Received: by 2002:a17:90a:fc82:: with SMTP id ci2mr28088790pjb.13.1571662799605; Mon, 21 Oct 2019 05:59:59 -0700 (PDT) Received: from titan.hq.cloud.yunionyun.com ([161.117.5.46]) by smtp.gmail.com with ESMTPSA id 20sm15880813pfp.153.2019.10.21.05.59.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Oct 2019 05:59:58 -0700 (PDT) From: Yousong Zhou To: jo@mein.io Date: Mon, 21 Oct 2019 12:59:24 +0000 Message-Id: <20191021125924.37223-2-yszhou4tech@gmail.com> In-Reply-To: <20191021061031.81230-1-yszhou4tech@gmail.com> References: <20191021061031.81230-1-yszhou4tech@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191021_060000_974596_2D814C89 X-CRM114-Status: UNSURE ( 9.25 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:442 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (yszhou4tech[at]gmail.com) -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_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 -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain Subject: [OpenWrt-Devel] [PATCH rpcd v2 6/6] main: exec_self: make clang analyzer happy X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yousong Zhou , ynezz@true.cz, openwrt-devel@lists.openwrt.org Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Signed-off-by: Yousong Zhou --- main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 1db3241..12cb4c5 100644 --- a/main.c +++ b/main.c @@ -47,12 +47,16 @@ static void exec_self(int argc, char **argv) { int i; - const char *cmd = rpc_exec_lookup(argv[0]); - char **args = calloc(argc + 1, sizeof(char *)); + const char *cmd; + char **args; - if (!cmd || !args) + cmd = rpc_exec_lookup(argv[0]); + if (!cmd) return; + args = calloc(argc + 1, sizeof(char *)); + if (!args) + return; for (i = 0; i < argc; i++) args[i] = argv[i];