pwntools-ruby icon indicating copy to clipboard operation
pwntools-ruby copied to clipboard

Bug: recvuntil

Open JonathanBeverley opened this issue 7 years ago • 2 comments

Tube::recvuntil optionally takes a timeout. If provided, it enters a loop like

while @timer.active?
  s = recv(1)
  return '' if s.empty?
  # process s
end

However, that return bails out of the whole function, not the @timer loop. Should be next if s.empty?

JonathanBeverley avatar Jan 30 '18 04:01 JonathanBeverley

Also affects Timer::recvpred

JonathanBeverley avatar Jan 30 '18 04:01 JonathanBeverley

The original design for the timer / tube things is that we assume that after setting timeout_raw, recv_raw would either:

  • Return some data in at most timeout_raw seconds.
  • Return empty string if no data is available in timeout_raw seconds.
  • Raise EOFError.

So we somewhat assume that recv_raw is a blocking call.

We should definitely document this better (and fix the outdated document after #87), and maybe also provide a fallback implementation for non-blocking recv_raw.

peter50216 avatar Feb 09 '18 15:02 peter50216