bad debugdump() causes SIGSEGV, partial sends not done right
The anonymous bug report #2822910 pointed out that debugdump() was stupidly called within the send_existing() function. At closer inspection was the report not only right, but it also revealed another problem to me: when the _libssh2_send() function returns after sending only a part of the buffer, it would then misbehave. This probably is very rare though, which must be the reason we haven't seen a bigger problem with this.
Этот коммит содержится в:
родитель
ba57d5ae3c
Коммит
dd38d0a929
@ -619,12 +619,18 @@ send_existing(LIBSSH2_SESSION * session, unsigned char *data,
|
||||
rc = _libssh2_send(session->socket_fd, &p->outbuf[p->osent], length,
|
||||
LIBSSH2_SOCKET_SEND_FLAGS(session));
|
||||
|
||||
if(rc > 0) {
|
||||
debugdump(session, "libssh2_transport_write send()",
|
||||
&p->outbuf[p->osent], rc);
|
||||
}
|
||||
|
||||
if (rc == length) {
|
||||
/* the remainder of the package was sent */
|
||||
LIBSSH2_FREE(session, p->outbuf);
|
||||
p->outbuf = NULL;
|
||||
p->ototal_num = 0;
|
||||
} else if (rc < 0) {
|
||||
}
|
||||
else if (rc < 0) {
|
||||
/* nothing was sent */
|
||||
if (errno != EAGAIN) {
|
||||
/* send failure! */
|
||||
@ -634,9 +640,7 @@ send_existing(LIBSSH2_SESSION * session, unsigned char *data,
|
||||
return PACKET_EAGAIN;
|
||||
}
|
||||
|
||||
debugdump(session, "libssh2_transport_write send()", &p->outbuf[p->osent],
|
||||
length);
|
||||
p->osent += length; /* we sent away this much data */
|
||||
p->osent += rc; /* we sent away this much data */
|
||||
|
||||
return PACKET_NONE;
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user