unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@yhbt.net>
To: meta@public-inbox.org
Subject: [PATCH] imap: quiet uninitialized variable warning on FETCH
Date: Tue, 15 Sep 2020 06:11:18 +0000	[thread overview]
Message-ID: <20200915061118.27220-1-e@yhbt.net> (raw)

This was triggered by blindly trying to FETCH an MSN (not
"UID FETCH") on an empty dummy inbox.  It's harmless, and
probably triggered by a wayward client or misbehaving bot.
---
 lib/PublicInbox/IMAP.pm | 2 +-
 t/imapd.t               | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index 2d0d005e..47c08aea 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -300,7 +300,7 @@ sub msn2uid ($) {
 # converts a set of message sequence numbers in requests to UIDs:
 sub msn_to_uid_range ($$) {
 	my $msn2uid = $_[0];
-	$_[1] =~ s!([0-9]+)!$msn2uid->[$1 - 1] // ($msn2uid->[-1] + 1)!sge;
+	$_[1] =~ s!([0-9]+)!$msn2uid->[$1 - 1] // ($msn2uid->[-1] // 0 + 1)!sge;
 }
 
 # called by PublicInbox::InboxIdle
diff --git a/t/imapd.t b/t/imapd.t
index cb95fa5d..c1c52839 100644
--- a/t/imapd.t
+++ b/t/imapd.t
@@ -371,6 +371,10 @@ EOF
 	@hits = $mic->search('SENTSINCE' => '18-Apr-2020');
 	is_deeply(\@hits, [], 'search on dummy with condition works');
 	ok(!$mic->search('SENTSINCE' => '18-Abr-2020'), 'bad month fails');
+	$mic->Uid(0);
+	my $ret = $mic->fetch_hash(2, 'RFC822');
+	is_deeply($ret, {},
+		'MSN FETCH on empty dummy will not trigger warnings, later');
 }); # each_inbox
 
 # message sequence numbers :<

                 reply	other threads:[~2020-09-15  6:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200915061118.27220-1-e@yhbt.net \
    --to=e@yhbt.net \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).