From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 733A09DE75 for ; Tue, 6 Jun 2023 14:05:54 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4CA0E344AD for ; Tue, 6 Jun 2023 14:05:24 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 6 Jun 2023 14:05:23 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E84D448C04 for ; Tue, 6 Jun 2023 14:05:22 +0200 (CEST) Date: Tue, 6 Jun 2023 14:05:22 +0200 From: Wolfgang Bumiller To: Thomas Lamprecht Cc: Proxmox VE development discussion , Dominik Csapak Message-ID: References: <20230606083914.1400960-1-d.csapak@proxmox.com> <20230606083914.1400960-2-d.csapak@proxmox.com> <7f0da808-115b-6f31-2cf2-3bd3f0e7e27b@proxmox.com> <3f88f726-9d89-3026-2a2c-4b3e9dbda7db@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3f88f726-9d89-3026-2a2c-4b3e9dbda7db@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.129 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pve-devel] [PATCH common v2 1/3] JSONSchema: add support for array parameter in api calls, cli and config X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Jun 2023 12:05:54 -0000 On Tue, Jun 06, 2023 at 12:45:57PM +0200, Thomas Lamprecht wrote: > Am 06/06/2023 um 11:41 schrieb Dominik Csapak: > >>>   +my $untaint_recursive; > >> > >> I got flash backs w.r.t. refcount cycles here keeping all variables, and thus memory > >> inside the body alive forever, don't we need a weaken? > >> > >> E.g., like we had to do in PVE::Status::Graphite's assemble. > > > > mhmm isn't that because there we use variables from outside the > > function? here we only use the parameters themselves > > I'm not 100% sure about the details, but since then, seeing something like > this pattern triggers my cycle instincts, I'd like to have that checked out > closely. I *do* prefer `my sub` these days. However, for recursive subs you need to `use feature 'current_sub'` to avoid ... well... leaks ;-) So: my sub untaint_recursive : prototype($) { use feature 'current_sub'; my ($arg) = @_; ... # For recursion: __SUB__->($stuff); ... } Given that this function shouldn't be leaky, you could keep it, or even pre-declare the sub to allow recursion: my sub untaint_recursive : prototype($); sub untaint_recursive : prototype($) { } however, `perlsub` explicitly states that this, too, can leak ;-)