Skip to content

Commit 44a22ab

Browse files
committed
Land #16640, Patch LDAP for sychronous reads
2 parents f036950 + 0c481ed commit 44a22ab

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/rex/proto/ldap.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@
44
# Monkeypatch upstream library, for now
55
# TODO: write a real LDAP client in Rex and migrate all consumers
66
class Net::LDAP::Connection # :nodoc:
7+
module SynchronousRead
8+
def read(length = nil, opts = {})
9+
data = ''
10+
loop do
11+
chunk = super(length - data.length)
12+
if chunk.nil?
13+
return data == '' ? nil : data
14+
end
15+
16+
data << chunk
17+
break if data.length == length
18+
end
19+
20+
data
21+
end
22+
end
723

824
def initialize(server)
925
begin
@@ -12,6 +28,7 @@ def initialize(server)
1228
'PeerPort' => server[:port],
1329
'Proxies' => server[:proxies]
1430
)
31+
@conn.extend(SynchronousRead)
1532
rescue SocketError
1633
raise Net::LDAP::LdapError, 'No such address or other socket error.'
1734
rescue Errno::ECONNREFUSED

0 commit comments

Comments
 (0)