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,
|
rc = _libssh2_send(session->socket_fd, &p->outbuf[p->osent], length,
|
||||||
LIBSSH2_SOCKET_SEND_FLAGS(session));
|
LIBSSH2_SOCKET_SEND_FLAGS(session));
|
||||||
|
|
||||||
|
if(rc > 0) {
|
||||||
|
debugdump(session, "libssh2_transport_write send()",
|
||||||
|
&p->outbuf[p->osent], rc);
|
||||||
|
}
|
||||||
|
|
||||||
if (rc == length) {
|
if (rc == length) {
|
||||||
/* the remainder of the package was sent */
|
/* the remainder of the package was sent */
|
||||||
LIBSSH2_FREE(session, p->outbuf);
|
LIBSSH2_FREE(session, p->outbuf);
|
||||||
p->outbuf = NULL;
|
p->outbuf = NULL;
|
||||||
p->ototal_num = 0;
|
p->ototal_num = 0;
|
||||||
} else if (rc < 0) {
|
}
|
||||||
|
else if (rc < 0) {
|
||||||
/* nothing was sent */
|
/* nothing was sent */
|
||||||
if (errno != EAGAIN) {
|
if (errno != EAGAIN) {
|
||||||
/* send failure! */
|
/* send failure! */
|
||||||
@ -634,9 +640,7 @@ send_existing(LIBSSH2_SESSION * session, unsigned char *data,
|
|||||||
return PACKET_EAGAIN;
|
return PACKET_EAGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
debugdump(session, "libssh2_transport_write send()", &p->outbuf[p->osent],
|
p->osent += rc; /* we sent away this much data */
|
||||||
length);
|
|
||||||
p->osent += length; /* we sent away this much data */
|
|
||||||
|
|
||||||
return PACKET_NONE;
|
return PACKET_NONE;
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user