From nobody Fri Dec 10 10:38:49 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8E72E18D6587; Fri, 10 Dec 2021 10:38:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J9S7F26cyz3C32; Fri, 10 Dec 2021 10:38:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 286AB18A6D; Fri, 10 Dec 2021 10:38:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BAAcnYg005849; Fri, 10 Dec 2021 10:38:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BAAcnnc005848; Fri, 10 Dec 2021 10:38:49 GMT (envelope-from git) Date: Fri, 10 Dec 2021 10:38:49 GMT Message-Id: <202112101038.1BAAcnnc005848@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: 6a5487e34b13 - stable/13 - libc sctp: fix sctp_getladdrs() when reporting no addresses List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6a5487e34b13f9b7e184a4cca23b715a76f2a375 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639132729; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xZ9EGD0LW3YRH6Qi7j29sovomUDTEq4cknsJXJabssc=; b=EAYMZ9jsFdkApYwnU9+dL2nuXL9hvRLlIcyoeSgp4WCGgY9cSlgGAUoZhuR2xfpIHuXqhd 1iVegFK0EEGnCpu6ZgUlnzxQqj9Or0o7T3pQG53Qp9YOOaBCJxIA10iK5y1CB826VnIesh fP59rVkQZaWQtHmg9u435tjcSpbjyQECz1Qj+Ls9IX2tAVVE9NxkQVDi+wee6wg7FKiPZ5 DenIjRyJjKylWhOII8jQv3e/sSw2le32RwFKrfU8Vx3B/o9pC80/HLgonU1eKYA0GiL+z6 r64416O75utIaD5iAwX5bk994vSu70JuPM35QiO+LGfdXTuYpVwcnP4W0N+oog== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639132729; a=rsa-sha256; cv=none; b=jg1H1zCDNfczpoppqJbvZq8rCBkT8Y/W07/k7092y3SsnFEORtmP/bR0R8XOdSUFiFaOYz X+L+lxJh0RviYDamA9WJMq92klOu6SDGsmHcevMe+/6dfM/Cv36dMWTSTZQtiwKQHTE8gI diidhtOFBVPVxf8cNyzhWliPffGskiecbHpgirYnEFbqzbZEzNAgzyxv36FveVrocAVoVX hNFSnor8ffbOPwa7VHpuA6lBMbuVVIZoNWOsm/EPZVcB5mUMSn/pwtHZCj/tgsotmSh9Bh sp25Norh3XYaODOeUjLSh0wXzuRsIn46mg0+OyhCjjwLcpz3z5MdI/4baEtysg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=6a5487e34b13f9b7e184a4cca23b715a76f2a375 commit 6a5487e34b13f9b7e184a4cca23b715a76f2a375 Author: Michael Tuexen AuthorDate: 2021-12-01 15:20:17 +0000 Commit: Michael Tuexen 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;