RFC 2683 section 3.2.1.5 recommends it:
> For its part, a server should allow for a command line of at least
> 8000 octets. This provides plenty of leeway for accepting reasonable
> length commands from clients. The server should send a BAD response
> to a command that does not end within the server's maximum accepted
> command length.
To conserve memory, we won't bother reading the entire line
before sending the BAD response and disconnecting them.
5322 => 'Internet message format (2008)',
3501 => 'IMAP4rev1',
2177 => 'IMAP IDLE',
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',
# 5032 = 'WITHIN search extension for IMAP',
4978 => 'IMAP COMPRESS Extension',
# 5182 = 'IMAP Extension for Referencing the Last SEARCH Result',
}
die "neither Email::Address::XS nor Mail::Address loaded: $@" if !$Address;
}
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 }
# changing this will cause grief for clients which cache
sub UID_BLOCK () { 50_000 }
my $rbuf = $self->{rbuf} // \(my $x = '');
my $line = index($$rbuf, "\n");
while ($line < 0) {
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");
}
$self->do_read($rbuf, LINE_MAX, length($$rbuf)) or return;
$line = index($$rbuf, "\n");
}