From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.1 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id A8F3E20183 for ; Mon, 28 Nov 2022 05:32:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1669613558; bh=wKLlcU/Av51MdeoroN31K3SRIQuoqessV2EKmpxnrg0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=AxGAdYsqHRvzNYw+3++DPzliAKb4DmoBZjMOgfaGq3RrQrzT8x0G1VCL9DLrvOGPd jyiPCBL9I74shS6NBhkgncQOy/jzOZFTUMMZVIrBbCgczQ+ikzwPEnDHOyfNz7Ukrd OrTA+T43j4Qc0qvtjxotGJm7YrEZkQCbI5ifsX/g= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 29/95] lei_mirror: defend against infinite loops Date: Mon, 28 Nov 2022 05:31:26 +0000 Message-Id: <20221128053232.291618-30-e@80x24.org> In-Reply-To: <20221128053232.291618-1-e@80x24.org> References: <20221128053232.291618-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: A reference chain of 1000 ought to be enough, I think... --- lib/PublicInbox/LeiMirror.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index 0f46d355..1d6ed51c 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -538,9 +538,13 @@ sub clone_all { # resolve references, deepest, first: while (scalar keys %$todo) { for my $x (keys %$todo) { + my $nr; # resolve multi-level references while (defined(my $nxt = $m->{$x}->{reference})) { exists($todo->{$nxt}) or last; + die < 1000; +E: dependency loop detected (`$x' => `$nxt') +EOM $x = $nxt; } my $y = delete $todo->{$x} // next; # already done