libc sctp: improve conformance of sctp_getpaddrs()

When there is no association, don't return -1 and indicate ENOENT,
but return 0 instead. This is specified in RFC 6458.

PR:		260117
MFC after:	1 week
This commit is contained in:
Michael Tuexen 2021-12-01 19:47:50 +01:00
parent 94a72c5ac4
commit 83a103ec42

View File

@ -405,7 +405,11 @@ sctp_getpaddrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs)
opt_len = (socklen_t)sizeof(uint32_t);
if (getsockopt(sd, IPPROTO_SCTP, SCTP_GET_REMOTE_ADDR_SIZE,
&size_of_addresses, &opt_len) != 0) {
return (-1);
if (errno == ENOENT) {
return (0);
} else {
return (-1);
}
}
opt_len = (socklen_t)((size_t)size_of_addresses + sizeof(struct sctp_getaddresses));
addrs = calloc(1, (size_t)opt_len);