Commit 071966e8 authored by Michael Tuexen's avatar Michael Tuexen
Browse files

libc sctp: fix sctp_getladdrs() when reporting no addresses

Section 9.5 of RFC 6458 (SCTP Socket API) requires that
sctp_getladdrs() returns 0 in case the socket is unbound. This
is the cause of reporting 0 addresses. So don't indicate an
error, just report this case as required.

PR:		260117
MFC after:	1 week
parent 629b5e87
...@@ -462,10 +462,6 @@ sctp_getladdrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs) ...@@ -462,10 +462,6 @@ sctp_getladdrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs)
&size_of_addresses, &opt_len) != 0) { &size_of_addresses, &opt_len) != 0) {
return (-1); return (-1);
} }
if (size_of_addresses == 0) {
errno = ENOTCONN;
return (-1);
}
opt_len = (socklen_t)((size_t)size_of_addresses + sizeof(struct sctp_getaddresses)); opt_len = (socklen_t)((size_t)size_of_addresses + sizeof(struct sctp_getaddresses));
addrs = calloc(1, (size_t)opt_len); addrs = calloc(1, (size_t)opt_len);
if (addrs == NULL) { if (addrs == NULL) {
...@@ -479,6 +475,10 @@ sctp_getladdrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs) ...@@ -479,6 +475,10 @@ sctp_getladdrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs)
free(addrs); free(addrs);
return (-1); return (-1);
} }
if (size_of_addresses == 0) {
free(addrs);
return (0);
}
*raddrs = &addrs->addr[0].sa; *raddrs = &addrs->addr[0].sa;
cnt = 0; cnt = 0;
sa = &addrs->addr[0].sa; sa = &addrs->addr[0].sa;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment