cuviper / ssh-pageant

An SSH authentication agent for Cygwin/MSYS to PuTTY's Pageant.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tolerate incomplete socket send/recv

cuviper opened this issue · comments

It's not guaranteed that a recv will get an atomic message. With "ssh-pageant -d" and looping "ssh-add -l" requests, I eventually see:

ssh-pageant: recv(0) = 4 (expected 5)

Currently when an incomplete message is detected, that connection is closed, though ssh-pageant will continue listening for new connections. It would be better to have per-connection buffers, so it can tolerate recv'ing partial chunks.

I'm not sure if send will realistically ever be partial, but it might as well be careful.

Allocate a buffer for each connection

Using distinct buffers allows resuming a partial send/recv. Just update
the pointer completed so far in that buffer and go back into the select
loop.

Closed by 47a34c7

Yeah, sends and receives can always be partial, and must never be relied on to be otherwise.

This commit does seem to fix my issues. Thanks!