unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] imap: fix uninitialized var on MSN search miss
Date: Tue,  5 Jan 2021 18:19:48 +0000
Message-ID: <20210105181948.4338-1-e@80x24.org> (raw)

It seems only triggered by bots trying to steal information.
---
 lib/PublicInbox/IMAP.pm | 2 +-
 t/imapd.t               | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index 68a7e050..226e98a2 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -1142,7 +1142,7 @@ sub search_common {
 		};
 		my $mset = $srch->mset($q, $opt);
 		my $uids = $srch->mset_to_artnums($mset, $opt);
-		msn_convert($self, $uids) if $want_msn;
+		msn_convert($self, $uids) if scalar(@$uids) && $want_msn;
 		"* SEARCH @$uids\r\n$tag OK Search done\r\n";
 	} else {
 		"$tag BAD Error\r\n";
diff --git a/t/imapd.t b/t/imapd.t
index 5d610dfd..1df9d26e 100644
--- a/t/imapd.t
+++ b/t/imapd.t
@@ -371,11 +371,13 @@ is(scalar keys %$ret, 3, 'got all 3 messages');
 
 SKIP: {
 	# do any clients use non-UID IMAP SEARCH?
-	skip 'Xapian missing', 2 if $level eq 'basic';
+	skip 'Xapian missing', 3 if $level eq 'basic';
 	my $x = $mic->search('all');
 	is_deeply($x, [1, 2, 3], 'MSN SEARCH works before rm');
 	$x = $mic->search(qw(header subject embedded));
 	is_deeply($x, [2], 'MSN SEARCH on Subject works before rm');
+	$x = $mic->search('FROM scraper@example.com');
+	is_deeply($x, [], "MSN SEARCH miss won't trigger warnings");
 }
 
 {

                 reply	other threads:[~2021-01-05 18:19 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=20210105181948.4338-1-e@80x24.org \
    --to=e@80x24.org \
    --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

unofficial mirror of meta@public-inbox.org

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://yhetil.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.mail.public-inbox.meta
	nntp://news.public-inbox.org/inbox.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git