Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Dec 2021 10:38:49 GMT
From:      Michael Tuexen <tuexen@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 6a5487e34b13 - stable/13 - libc sctp: fix sctp_getladdrs() when reporting no addresses
Message-ID:  <202112101038.1BAAcnnc005848@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by tuexen:

URL: https://cgit.FreeBSD.org/src/commit/?id=6a5487e34b13f9b7e184a4cca23b715a76f2a375

commit 6a5487e34b13f9b7e184a4cca23b715a76f2a375
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2021-12-01 15:20:17 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2021-12-10 10:38:31 +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
    
    (cherry picked from commit 071966e874ed472bdac031b7e89d08bacf8bbbc4)
---
 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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202112101038.1BAAcnnc005848>