From nobody Wed Dec 01 15:25:07 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 22B1418B2E50; Wed, 1 Dec 2021 15:25:08 +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 4J42vl62Trz3KCk; Wed, 1 Dec 2021 15:25:07 +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 AEF6044C1; Wed, 1 Dec 2021 15:25:07 +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 1B1FP75J079386; Wed, 1 Dec 2021 15:25:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B1FP7R2079385; Wed, 1 Dec 2021 15:25:07 GMT (envelope-from git) Date: Wed, 1 Dec 2021 15:25:07 GMT Message-Id: <202112011525.1B1FP7R2079385@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 071966e874ed - main - 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/main X-Git-Reftype: branch X-Git-Commit: 071966e874ed472bdac031b7e89d08bacf8bbbc4 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638372307; 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=quUJ9v2kjsEa3OeQIjbkY+1Aqedfa5+22zmpbS9hY0Q=; b=IwDLrLulrfpgbx6vq6S1u+sA/y8spw/yES3yb5y/5jG034pWiY7j6PYCtVz9QuMClqLnbM QyCJj53BapzecTZjOj1gNdoBe69NHEcePf64IYdNPf6FD0Xjrj8GC1DeTDaLdXxTlpXNgz 8G57z8vuVukvkmVGe/7ObPEaOjC7YlmZmhvJ1CWiNW+juHjGqhCeWH13+mxkcy2ljC8dki 1tj++hsBv633vC/oglRTW+8vnEDuMSXukNjFvK/TjZht0NDQBG3FMe+gM0/Pa7Z9G4UoZm FKII99cZtMFho9jGj/Mgt1flv0PxncZrvjUY4ZqhcMeOrsxfrOqEA59TN++szg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638372307; a=rsa-sha256; cv=none; b=BZ0WHkZdz3US5YXOzq5MdMgb5yeapA0xbR20ay3iWTvN4HCmDLYHLKB6DXbt4DemCvzpWO SKt722DKUhPyrxLaXcOR02hkB4gk0rOQuN+iTHrJNciHBvmUVNh0EUmCveGq4Vh4fZHE3c FJ3r0biRcWWnIimoye7/K3nLrqHcomZGGYsVTfYjPvVBgNxjhWtYgSPba/7oIvqcLHAhXV yvgXRF4RgnJ3GqJJ7cPkYaA7r0/GOWSMb/bfSkOhX8J5HUAkU4+ehDta36HALttYwIIIMK ZBOK63obfw6lT1yEk3AXoVOwPdVtmV5rvS93iaozOp+F6CAT9Pq/sgs+p3k8bg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=071966e874ed472bdac031b7e89d08bacf8bbbc4 commit 071966e874ed472bdac031b7e89d08bacf8bbbc4 Author: Michael Tuexen AuthorDate: 2021-12-01 15:20:17 +0000 Commit: Michael Tuexen 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;