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.0 required=3.0 tests=ALL_TRUSTED,BAYES_00, T_SCC_BODY_TEXT_LINE 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 4029A1F4D8 for ; Mon, 18 Apr 2022 09:50:05 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/4] lei: clobber recvmsg buffer on errors Date: Mon, 18 Apr 2022 09:50:01 +0000 Message-Id: <20220418095004.466-2-e@80x24.org> In-Reply-To: <20220418095004.466-1-e@80x24.org> References: <20220418095004.466-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: It will be necessary when we drop the Inline::C requirement since the pure Perl Linux syscall recvmsg implementation. This likely would've caused errors for Socket::MsgHdr users without Inline::C, but I haven't tested it since it's a rare configuration. --- lib/PublicInbox/LEI.pm | 1 + lib/PublicInbox/LeiSelfSocket.pm | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index a7ddc21f..9ab91714 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -1149,6 +1149,7 @@ sub event_step { if (scalar(@fds) == 1 && !defined($fds[0])) { return if $! == EAGAIN; die "recvmsg: $!" if $! != ECONNRESET; + $buf = ''; @fds = (); # for open loop below: } for (@fds) { open my $rfh, '+<&=', $_ } diff --git a/lib/PublicInbox/LeiSelfSocket.pm b/lib/PublicInbox/LeiSelfSocket.pm index dd64b6cf..860020cb 100644 --- a/lib/PublicInbox/LeiSelfSocket.pm +++ b/lib/PublicInbox/LeiSelfSocket.pm @@ -29,6 +29,7 @@ sub event_step { if (scalar(@fds) == 1 && !defined($fds[0])) { return if $!{EAGAIN}; die "recvmsg: $!" unless $!{ECONNRESET}; + $buf = ''; } else { # just in case open so perl can auto-close them: for (@fds) { open my $fh, '+<&=', $_ }; }