mirror of
https://github.com/libssh2/libssh2.git
synced 2026-10-24 03:48:58 +03:00
agent: fix potential infinite loop while receiving data from SSH agent
If the local SSH agent terminates while we are receiving data from it. Refs: https://learn.microsoft.com/windows/win32/api/fileapi/nf-fileapi-readfile#pipes https://linux.die.net/man/2/recv https://www.man7.org/linux/man-pages/man2/recv.2.html Reported-by: afldl on github Closes #2414
This commit is contained in:
@@ -425,11 +425,14 @@ cleanup:
|
||||
int rc; \
|
||||
\
|
||||
while(*(total) < (length)) { \
|
||||
if(!(agent)->pending_io) \
|
||||
if(!(agent)->pending_io) { \
|
||||
ret = (func)((agent)->pipe, (char *)(buffer) + *(total), \
|
||||
(DWORD)((length) - *(total)), \
|
||||
&bytes_transferred, \
|
||||
&(agent)->overlapped); \
|
||||
if(ret && !bytes_transferred) \
|
||||
return LIBSSH2_ERROR_SOCKET_DISCONNECT; \
|
||||
} \
|
||||
else \
|
||||
ret = GetOverlappedResult((agent)->pipe, \
|
||||
&(agent)->overlapped, \
|
||||
@@ -619,6 +622,8 @@ static int agent_connect_unix(LIBSSH2_AGENT *agent)
|
||||
flags, abstract); \
|
||||
if(rc < 0) \
|
||||
return rc; \
|
||||
else if(!rc) \
|
||||
return LIBSSH2_ERROR_SOCKET_DISCONNECT; \
|
||||
\
|
||||
finished += rc; \
|
||||
} \
|
||||
|
||||
Reference in New Issue
Block a user