From patchwork Tue Aug 29 11:58:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Shiu X-Patchwork-Id: 1827230 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=H+1lzUHp; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=m8LWEqNX; 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 4RZmJ6172Lz1yfy for ; Tue, 29 Aug 2023 22:02:13 +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:Cc :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=g8TINFbet5f2on24DQRNY4NwOnOPJ4p9wZZFZjtFh3k=; b=H+1lzUHpdsRRb9 ps+UbeHXHwPAop/m11yDGRZJ+jn2K0e40lGXG2X0TwM1hM7AH/3xt9JQjVq/wZPPWtcKMhP7jsKWr edlORdNl0Pm5f6g04focYbYmzoN3MUubXfTUtBrq52XuxwRfev9EqlfFEf3ThiTjpbEswdd6DgxO7 87yuFUBPNJ/WB9vj8dLabAwynTSW41J9wnHJkrEa8G10iLfW7Vc8pBVS6YAB8H08yyR9NGf/k62TX 2OtZufB7kMCzUOThhtiaWv8u+BBVnbcpfs0+BdgX3k05XSmoUZe7J+VjK1DfJpa9bgNi3wV3ISWkU fVz1RHv7cD61zdMf2uxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qaxN8-00BSIY-0r; Tue, 29 Aug 2023 11:59:02 +0000 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qaxN5-00BSIC-1A for openwrt-devel@lists.openwrt.org; Tue, 29 Aug 2023 11:59:00 +0000 Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3a88ef9444bso3026773b6e.1 for ; Tue, 29 Aug 2023 04:58:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693310336; x=1693915136; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=j54XkZMyBfPEju0J4jjITUz+2p7kyfnlXRpgf/OYWh0=; b=m8LWEqNXMDjPdjHNBMln1X4OHKnKdqxYIt5pxh3BnI6lZA8paX5jjJfcVyOkSq77PL vZo4v0ocOKWo1/P3BJp2Tp/mKdTIWJpbqJUw1nRqg+kurtOH5SD9lq/Yl+/maqkQelWg Rp7T8JXgX1bDWaTC8cnCeO/MWCEWI8V0AEXFSaeh5ON5xQbwjrG8TpBITt+U7Ex9sJ6N JDYs7ftXQ+NlkmsHEhsj5LOoUMd6IUEWMRrJxcfNWExy4C8BBw8poTISFaiww/FLXO81 +nYxBOUMKKqdSbQfESSnGaxHMJu7Gb+tz2d2aWazz3pAoXjnBuvbLqMx6P7r1h/EB3JJ 2SFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693310336; x=1693915136; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=j54XkZMyBfPEju0J4jjITUz+2p7kyfnlXRpgf/OYWh0=; b=SsLDqm1pRst5eCAI12IR/oicjF2ZLSyEXnryNJnQBhpr5LlWJkFJHGmvD5Pg3CB55N B2bwS8cIwyNIoOTEyFhiZHZUHrXvQgzLttbjHfysudeC9wbch2d1waHFeiZOZgdoCG6u QIUaMwyUpuRiZ6rDxdTcvJB1irbUkeOTpKaLlUBED3ulqinPL+zwlXJNIomkrFEmQnh6 UX5+/RWHNiRuEDfv5+oEZn6GcBHXM+RiJYMvkGFMtvElkK61LNJXW8P/90+WVOXuD0wo a3Hkl8MUUNv954anYLk54Ol0QbWXEjd++aRbM5Di+WrNO5+HsaoBfpHYx9mTUWVn4Og0 LyfQ== X-Gm-Message-State: AOJu0YyaSYX55LCANsrkUbC04IKGNEbgxSNbS0kG0bcLoP8ASZFRFL9M vfKrGgMonaHt0jSUFDjiCH3SANPUqz5dYw== X-Google-Smtp-Source: AGHT+IHKiHKneyW9y2KnKUrdVpEX66bNSGb6Evo77fTzvuZH1YAdnF+foPcoBJGtzFjxjKC5rkMDaQ== X-Received: by 2002:a54:4e14:0:b0:3a0:3495:c8d4 with SMTP id a20-20020a544e14000000b003a03495c8d4mr12945672oiy.28.1693310336401; Tue, 29 Aug 2023 04:58:56 -0700 (PDT) Received: from jeff-P45VA.gemteks.com (210-61-29-25.hinet-ip.hinet.net. [210.61.29.25]) by smtp.googlemail.com with ESMTPSA id s60-20020a17090a69c200b00263cca08d95sm11354015pjj.55.2023.08.29.04.58.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 04:58:56 -0700 (PDT) From: Jeff Shiu To: openwrt-devel@lists.openwrt.org Cc: Jeff Shiu Subject: [PATCH uci] uci: decrease the n_section when section is freed Date: Tue, 29 Aug 2023 19:58:46 +0800 Message-Id: <20230829115846.1231689-1-waherob42858@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230829_045859_417538_B86AF9D5 X-CRM114-Status: GOOD ( 10.74 ) X-Spam-Score: 0.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 package n_section counter increases when a section is allocated but does not decrease when a section is freed. Since the anonymous section name is comprised of the section counter, if the package is not reloaded, an incorrect count will result in operating on the wrong section. Content analysis details: (0.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 [2607:f8b0:4864:20:0:0:0:22d 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.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [waherob42858[at]gmail.com] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [waherob42858[at]gmail.com] -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 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 package n_section counter increases when a section is allocated but does not decrease when a section is freed. Since the anonymous section name is comprised of the section counter, if the package is not reloaded, an incorrect count will result in operating on the wrong section. Signed-off-by: Jeff Shiu --- list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list.c b/list.c index 304c9e1..6545ba5 100644 --- a/list.c +++ b/list.c @@ -228,6 +228,7 @@ uci_free_section(struct uci_section *s) if ((s->type != uci_dataptr(s)) && (s->type != NULL)) free(s->type); + s->package->n_section--; uci_free_element(&s->e); } @@ -734,7 +735,6 @@ int uci_set(struct uci_context *ctx, struct uci_ptr *ptr) if (ptr->section == old->e.name) ptr->section = ptr->s->e.name; uci_free_section(old); - ptr->s->package->n_section--; } } else { UCI_THROW(ctx, UCI_ERR_INVAL);