From c100879166cbbd6c2481ce68a549dab7d018d826 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 24 Jun 2019 02:52:32 +0000 Subject: http|nntp: be explicit about bytes::length on rbuf It should not matter because our rbuf is always from a socket without encoding layers, but this makes things easier to follow. --- lib/PublicInbox/HTTP.pm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/PublicInbox/HTTP.pm') diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm index e132c610..fbca9a54 100644 --- a/lib/PublicInbox/HTTP.pm +++ b/lib/PublicInbox/HTTP.pm @@ -76,7 +76,7 @@ sub event_step { # called by PublicInbox::DS return read_input($self) if defined $self->{env}; - my $off = length($self->{rbuf}); + my $off = bytes::length($self->{rbuf}); my $r = sysread($self->{sock}, $self->{rbuf}, 8192, $off); if (defined $r) { return $self->close if $r == 0; @@ -98,7 +98,7 @@ sub rbuf_process { # (they are rarely-used and git (as of 2.7.2) does not use them) if ($r == -1 || $env{HTTP_TRAILER} || # this length-check is necessary for PURE_PERL=1: - ($r == -2 && length($self->{rbuf}) > 0x4000)) { + ($r == -2 && bytes::length($self->{rbuf}) > 0x4000)) { return quit($self, 400); } return $self->watch_in1 if $r < 0; # incomplete @@ -375,12 +375,12 @@ sub read_input_chunked { # unlikely... if ($len == CHUNK_ZEND) { $$rbuf =~ s/\A\r\n//s and return app_dispatch($self, $input); - return quit($self, 400) if length($$rbuf) > 2; + return quit($self, 400) if bytes::length($$rbuf) > 2; } if ($len == CHUNK_END) { if ($$rbuf =~ s/\A\r\n//s) { $len = CHUNK_START; - } elsif (length($$rbuf) > 2) { + } elsif (bytes::length($$rbuf) > 2) { return quit($self, 400); } } @@ -390,14 +390,14 @@ sub read_input_chunked { # unlikely... if (($len + -s $input) > $MAX_REQUEST_BUFFER) { return quit($self, 413); } - } elsif (length($$rbuf) > CHUNK_MAX_HDR) { + } elsif (bytes::length($$rbuf) > CHUNK_MAX_HDR) { return quit($self, 400); } # will break from loop since $len >= 0 } if ($len < 0) { # chunk header is trickled, read more - my $off = length($$rbuf); + my $off = bytes::length($$rbuf); my $r = sysread($sock, $$rbuf, 8192, $off); return recv_err($self, $r, $len) unless $r; # (implicit) goto chunk_start if $r > 0; -- cgit v1.2.3-24-ge0c7