From 2c001a1b3acf5425c3f0077ffb9cfcabd8cc611c Mon Sep 17 00:00:00 2001 From: Oskar Eichler Date: Thu, 27 Aug 2026 22:45:27 +0300 Subject: [PATCH] Reject negative read lengths before changing the buffer --- lib/net/protocol.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb index 7e42d22..d5bf528 100644 --- a/lib/net/protocol.rb +++ b/lib/net/protocol.rb @@ -189,6 +189,7 @@ def close public def read(len, dest = ''.b, ignore_eof = false) + raise ArgumentError, "negative length #{len} given" if len < 0 LOG "reading #{len} bytes..." read_bytes = 0 begin