Documentation/standards.perl | 1 + lib/PublicInbox/IMAP.pm | 7 +++++-- diff --git a/Documentation/standards.perl b/Documentation/standards.perl index 8fc852c722bae5e48d6bcd3686ee29f7ea442662..b4bda8a9c06801df7be144e5606c66b7ce8017b6 100755 --- a/Documentation/standards.perl +++ b/Documentation/standards.perl @@ -44,6 +44,7 @@ 2822 => 'Internet message format (2001)', 5322 => 'Internet message format (2008)', 3501 => 'IMAP4rev1', 2177 => 'IMAP IDLE', + 2683 => 'IMAP4 Implementation Recommendations', # 5032 = 'WITHIN search extension for IMAP', 4978 => 'IMAP COMPRESS Extension', # 5182 = 'IMAP Extension for Referencing the Last SEARCH Result', diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm index b3c449b0712778b571ab2cbbb0d5e24b72e53c65..2e50415de57367b4f6b996c1f372ff21f1042ceb 100644 --- a/lib/PublicInbox/IMAP.pm +++ b/lib/PublicInbox/IMAP.pm @@ -36,7 +36,7 @@ $Address = $mod and last; } die "neither Email::Address::XS nor Mail::Address loaded: $@" if !$Address; -sub LINE_MAX () { 512 } # does RFC 3501 have a limit like RFC 977? +sub LINE_MAX () { 8000 } # RFC 2683 3.2.1.5 # changing this will cause grief for clients which cache sub UID_BLOCK () { 50_000 } @@ -1170,7 +1170,10 @@ my $rbuf = $self->{rbuf} // \(my $x = ''); my $line = index($$rbuf, "\n"); while ($line < 0) { - return $self->close if length($$rbuf) >= LINE_MAX; + if (length($$rbuf) >= LINE_MAX) { + $self->write(\"\* BAD request too long\r\n"); + return $self->close; + } $self->do_read($rbuf, LINE_MAX, length($$rbuf)) or return; $line = index($$rbuf, "\n"); }