lib/PublicInbox/HTTP.pm | 12 ++++++------ lib/PublicInbox/NNTP.pm | 6 +++--- diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm index e132c6105f4ac9f66f495bd21a45753125e0b63c..fbca9a54720b774c64a9947bf69755c8fcb435a2 100644 --- a/lib/PublicInbox/HTTP.pm +++ b/lib/PublicInbox/HTTP.pm @@ -76,7 +76,7 @@ # otherwise we can be buffering infinitely w/o backpressure 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 @@ # We do not support Trailers in chunked requests, for now # (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 @@ while (1) { # chunk start 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 @@ $len = hex $1; 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; diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index 6a582ea41397412253afb5503f79a23610c78c16..a9e54a68999857fe1a3ea8b82146ebf1321f215e 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -243,7 +243,7 @@ $gmt = 1; } my @now = $gmt ? gmtime : localtime; my ($YYYY, $MM, $DD); - if (length($date) == 8) { # RFC 3977 allows YYYYMMDD + if (bytes::length($date) == 8) { # RFC 3977 allows YYYYMMDD ($YYYY, $MM, $DD) = unpack('A4A2A2', $date); } else { # legacy clients send YYMMDD ($YYYY, $MM, $DD) = unpack('A2A2A2', $date); @@ -944,7 +944,7 @@ my $rbuf = \($self->{rbuf}); my $r; if (index($$rbuf, "\n") < 0) { - my $off = length($$rbuf); + my $off = bytes::length($$rbuf); $r = sysread($self->{sock}, $$rbuf, LINE_MAX, $off); unless (defined $r) { return $! == EAGAIN ? $self->watch_in1 : $self->close; @@ -964,7 +964,7 @@ out($self, "[$fd] %s - %0.6f$d", $line, now() - $t0); } return $self->close if $r < 0; - my $len = length($$rbuf); + my $len = bytes::length($$rbuf); return $self->close if ($len >= LINE_MAX); update_idle_time($self);