From 5d2a518ef6aa4936be79758eb6d211c32a3ec675 Mon Sep 17 00:00:00 2001 From: CPANSec Security Scanner Bot Date: Tue, 24 Nov 2026 14:30:01 +0000 Subject: [PATCH] Net::Server::Proto::SSLEAY: return undef from getline at end of stream getline returns whatever read_until collected and ignores the status it reports. Once the peer has closed the connection, read_until stops at the first failed sysread with nothing read, so every call to getline returns a defined empty string instead of undef. STDIN is tied to the client socket, so a handler that reads with while (), as the default process_request does, never sees end of file and spins at full CPU; the default handler re-arms its alarm on every pass, so the alarm never fires either. Return undef (an empty list in list context) when read_until reports no match and nothing was read, as a readline on a plain socket does at end of file. A partial final line without a line terminator is still returned as it is. Notes for deciding whether to apply this patch: - getline now returns undef at end of stream. A final line without a line terminator is still returned. - getlines still returns a trailing empty string at end of stream. It does not loop, and is not changed here. - Not tested on a running server. It was checked by review and by applying it to Net-Server 2.018. - Applies on its own to Net-Server 2.018, and together with the other CPANSec patches for Net-Server 2.018 when they are applied in CVE-ID order. --- lib/Net/Server/Proto/SSLEAY.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Net/Server/Proto/SSLEAY.pm b/lib/Net/Server/Proto/SSLEAY.pm index c395b6e..e55e200 100644 --- a/lib/Net/Server/Proto/SSLEAY.pm +++ b/lib/Net/Server/Proto/SSLEAY.pm @@ -387,6 +387,7 @@ sub syswrite { sub getline { my $client = shift; my ($ok, $line) = $client->read_until($client->SSL_max_getline_length, $/); + return if !$ok && !length $line; # end of stream (or read error) with nothing read return $line; } -- 2.53.0