Skip to content

Commit 32746e0

Browse files
committed
Land rapid7#4631, @bcook-r7's fix for rapid7#4625 pkt requeue logic
2 parents fc016fe + 65d71a5 commit 32746e0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/rex/post/meterpreter/packet_dispatcher.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,14 @@ def monitor_socket
355355

356356
begin
357357
if ! dispatch_inbound_packet(pkt)
358-
# Only requeue packets newer than the timeout
359-
if (::Time.now.to_i - pkt.created_at.to_i > PacketTimeout)
358+
# Keep Packets in the receive queue until a handler is registered
359+
# for them. Packets will live in the receive queue for up to
360+
# PacketTimeout, after which they will be dropped.
361+
#
362+
# A common reason why there would not immediately be a handler for
363+
# a received Packet is in channels, where a connection may
364+
# open and receive data before anything has asked to read.
365+
if (::Time.now.to_i - pkt.created_at.to_i < PacketTimeout)
360366
incomplete << pkt
361367
end
362368
end

0 commit comments

Comments
 (0)