Fix for possible leaks or double frees (#968)
Этот коммит содержится в:
родитель
cf1cad407a
Коммит
e39e44fdfd
@ -131,12 +131,14 @@ iperf_sctp_accept(struct iperf_test * test)
|
|||||||
|
|
||||||
if (Nread(s, cookie, COOKIE_SIZE, Psctp) < 0) {
|
if (Nread(s, cookie, COOKIE_SIZE, Psctp) < 0) {
|
||||||
i_errno = IERECVCOOKIE;
|
i_errno = IERECVCOOKIE;
|
||||||
|
close(s);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(test->cookie, cookie) != 0) {
|
if (strncmp(test->cookie, cookie, COOKIE_SIZE) != 0) {
|
||||||
if (Nwrite(s, (char*) &rbuf, sizeof(rbuf), Psctp) < 0) {
|
if (Nwrite(s, (char*) &rbuf, sizeof(rbuf), Psctp) < 0) {
|
||||||
i_errno = IESENDMESSAGE;
|
i_errno = IESENDMESSAGE;
|
||||||
|
close(s);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
close(s);
|
close(s);
|
||||||
@ -240,9 +242,11 @@ iperf_sctp_listen(struct iperf_test *test)
|
|||||||
|
|
||||||
/* servers must call sctp_bindx() _instead_ of bind() */
|
/* servers must call sctp_bindx() _instead_ of bind() */
|
||||||
if (!TAILQ_EMPTY(&test->xbind_addrs)) {
|
if (!TAILQ_EMPTY(&test->xbind_addrs)) {
|
||||||
freeaddrinfo(res);
|
if (iperf_sctp_bindx(test, s, IPERF_SCTP_SERVER)) {
|
||||||
if (iperf_sctp_bindx(test, s, IPERF_SCTP_SERVER))
|
close(s);
|
||||||
|
freeaddrinfo(res);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
if (bind(s, (struct sockaddr *) res->ai_addr, res->ai_addrlen) < 0) {
|
if (bind(s, (struct sockaddr *) res->ai_addr, res->ai_addrlen) < 0) {
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
@ -473,8 +477,11 @@ iperf_sctp_connect(struct iperf_test *test)
|
|||||||
|
|
||||||
/* clients must call bind() followed by sctp_bindx() before connect() */
|
/* clients must call bind() followed by sctp_bindx() before connect() */
|
||||||
if (!TAILQ_EMPTY(&test->xbind_addrs)) {
|
if (!TAILQ_EMPTY(&test->xbind_addrs)) {
|
||||||
if (iperf_sctp_bindx(test, s, IPERF_SCTP_CLIENT))
|
if (iperf_sctp_bindx(test, s, IPERF_SCTP_CLIENT)) {
|
||||||
|
freeaddrinfo(server_res);
|
||||||
|
close(s);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO support sctp_connectx() to avoid heartbeating. */
|
/* TODO support sctp_connectx() to avoid heartbeating. */
|
||||||
@ -486,12 +493,12 @@ iperf_sctp_connect(struct iperf_test *test)
|
|||||||
i_errno = IESTREAMCONNECT;
|
i_errno = IESTREAMCONNECT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
freeaddrinfo(server_res);
|
|
||||||
|
|
||||||
/* Send cookie for verification */
|
/* Send cookie for verification */
|
||||||
if (Nwrite(s, test->cookie, COOKIE_SIZE, Psctp) < 0) {
|
if (Nwrite(s, test->cookie, COOKIE_SIZE, Psctp) < 0) {
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
close(s);
|
close(s);
|
||||||
|
freeaddrinfo(server_res);
|
||||||
errno = saved_errno;
|
errno = saved_errno;
|
||||||
i_errno = IESENDCOOKIE;
|
i_errno = IESENDCOOKIE;
|
||||||
return -1;
|
return -1;
|
||||||
@ -515,6 +522,7 @@ iperf_sctp_connect(struct iperf_test *test)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
freeaddrinfo(server_res);
|
||||||
return s;
|
return s;
|
||||||
#else
|
#else
|
||||||
i_errno = IENOSCTP;
|
i_errno = IENOSCTP;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user