1
1

Fix for possible leaks or double frees (#968)

Этот коммит содержится в:
Michal Ruprich 2020-05-05 00:05:18 +02:00 коммит произвёл GitHub
родитель cf1cad407a
Коммит e39e44fdfd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23

Просмотреть файл

@ -131,12 +131,14 @@ iperf_sctp_accept(struct iperf_test * test)
if (Nread(s, cookie, COOKIE_SIZE, Psctp) < 0) {
i_errno = IERECVCOOKIE;
close(s);
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) {
i_errno = IESENDMESSAGE;
close(s);
return -1;
}
close(s);
@ -240,9 +242,11 @@ iperf_sctp_listen(struct iperf_test *test)
/* servers must call sctp_bindx() _instead_ of bind() */
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;
}
} else
if (bind(s, (struct sockaddr *) res->ai_addr, res->ai_addrlen) < 0) {
saved_errno = errno;
@ -473,8 +477,11 @@ iperf_sctp_connect(struct iperf_test *test)
/* clients must call bind() followed by sctp_bindx() before connect() */
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;
}
}
/* TODO support sctp_connectx() to avoid heartbeating. */
@ -486,12 +493,12 @@ iperf_sctp_connect(struct iperf_test *test)
i_errno = IESTREAMCONNECT;
return -1;
}
freeaddrinfo(server_res);
/* Send cookie for verification */
if (Nwrite(s, test->cookie, COOKIE_SIZE, Psctp) < 0) {
saved_errno = errno;
close(s);
freeaddrinfo(server_res);
errno = saved_errno;
i_errno = IESENDCOOKIE;
return -1;
@ -515,6 +522,7 @@ iperf_sctp_connect(struct iperf_test *test)
return -1;
}
freeaddrinfo(server_res);
return s;
#else
i_errno = IENOSCTP;