git: 071966e874ed - main - libc sctp: fix sctp_getladdrs() when reporting no addresses
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 01 Dec 2021 15:25:07 UTC
The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=071966e874ed472bdac031b7e89d08bacf8bbbc4 commit 071966e874ed472bdac031b7e89d08bacf8bbbc4 Author: Michael Tuexen <tuexen@FreeBSD.org> AuthorDate: 2021-12-01 15:20:17 +0000 Commit: Michael Tuexen <tuexen@FreeBSD.org> CommitDate: 2021-12-01 15:25:01 +0000 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 --- lib/libc/net/sctp_sys_calls.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libc/net/sctp_sys_calls.c b/lib/libc/net/sctp_sys_calls.c index 3249eeaa4c4e..615b14ede5aa 100644 --- a/lib/libc/net/sctp_sys_calls.c +++ b/lib/libc/net/sctp_sys_calls.c @@ -462,10 +462,6 @@ sctp_getladdrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs) &size_of_addresses, &opt_len) != 0) { return (-1); } - if (size_of_addresses == 0) { - errno = ENOTCONN; - return (-1); - } opt_len = (socklen_t)((size_t)size_of_addresses + sizeof(struct sctp_getaddresses)); addrs = calloc(1, (size_t)opt_len); if (addrs == NULL) { @@ -479,6 +475,10 @@ sctp_getladdrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs) free(addrs); return (-1); } + if (size_of_addresses == 0) { + free(addrs); + return (0); + } *raddrs = &addrs->addr[0].sa; cnt = 0; sa = &addrs->addr[0].sa;