From nobody Wed Dec 1 09:16:47 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 23E5218A430D; Wed, 1 Dec 2021 09:16: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 4J3tkm27gyz3mKG; Wed, 1 Dec 2021 09:16:48 +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 1679227194; Wed, 1 Dec 2021 09:16:48 +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 1B19GlMp086920; Wed, 1 Dec 2021 09:16:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B19GlEG086919; Wed, 1 Dec 2021 09:16:47 GMT (envelope-from git) Date: Wed, 1 Dec 2021 09:16:47 GMT Message-Id: <202112010916.1B19GlEG086919@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: dabd8bf9145a - main - libc sctp: fix sctp_getladdrs() for 64-bit BE platforms 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: dabd8bf9145a0a7255473a482e2ccf31919c3089 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638350208; 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=4kwX1OINUPdUfDUzHPtjq6ugUqFfV8zfDdRBAbG3Hwk=; b=cwEnq4K+xv6TnKoU1Gx+V/BsOmj4TU21dOzIuHmeKqrAr81Z96YKoyrh8hMnHOyQVJ49V+ j7v8HBKASdW/DPG1qE+G5cF8AB29wHCbUn9fGT6f+mk0dHj2WvfnkmH6A38qHCHWB3MiTP RFg+VMuNlDNeSt2vDQmlpSeXvH6zEHjp8tfjgNGp4ywoeqnvSpWtME3jtza9HkuYHPpxR8 Bupjd8gpmR2m+j1dCmQ/BTpukXOrobRuyZswhAysnv3cCe7b6AKPKhTlBKlKtnlpjdfL1L xKKwXqYvzw3VCtpluQnFMdPf/TvfvE5TBu22+3ORzJUOdTiVotbCU3L24uLO5Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638350208; a=rsa-sha256; cv=none; b=tcnl0QRn8Ri7miPU7zLtcqMB/1NnjKl9a7UH0MMgV91sH7USdBv2tK9uv6CROozupnfasv IsUjg8QckJkapzz4yM8XIhJ8HnDgCT4KrspLCuQbRB9Ip+A7j0MdkvyVDxpC2KQ2S6AgCW TM+S5dX/wixKNbqCYe0L5E/9guUpZLerFw2/7Ma2/lwSd+6TDQ5aQDvURjrpvsHAyBjoLE Q47dXsdzO3+uNT8Mck0My38A6i2r9RD0+MURwR156aM3l2fJzcDHmqUzD+jd3wLsUcjg38 9EIBACYkeNVbZbiCLiIiLHZlg0EP5roa19cHjSKarAi2lTuApJmly9mSmZEudw== 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=dabd8bf9145a0a7255473a482e2ccf31919c3089 commit dabd8bf9145a0a7255473a482e2ccf31919c3089 Author: Michael Tuexen AuthorDate: 2021-12-01 09:13:20 +0000 Commit: Michael Tuexen CommitDate: 2021-12-01 09:13:20 +0000 libc sctp: fix sctp_getladdrs() for 64-bit BE platforms When calling getsockopt() with SCTP_GET_LOCAL_ADDR_SIZE, use a pointer to a 32-bit variable, since this is what the kernel expects. While there, do some cleanups. MFC after: 1 week --- lib/libc/net/sctp_sys_calls.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/libc/net/sctp_sys_calls.c b/lib/libc/net/sctp_sys_calls.c index 66a0f6adac3a..5acb957c3d3f 100644 --- a/lib/libc/net/sctp_sys_calls.c +++ b/lib/libc/net/sctp_sys_calls.c @@ -391,23 +391,23 @@ sctp_getpaddrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs) { struct sctp_getaddresses *addrs; struct sockaddr *sa; - sctp_assoc_t asoc; caddr_t lim; socklen_t opt_len; + uint32_t size_of_addresses; int cnt; if (raddrs == NULL) { errno = EFAULT; return (-1); } - asoc = id; - opt_len = (socklen_t)sizeof(sctp_assoc_t); + /* When calling getsockopt(), the value contains the assoc_id. */ + size_of_addresses = (uint32_t)id; + opt_len = (socklen_t)sizeof(uint32_t); if (getsockopt(sd, IPPROTO_SCTP, SCTP_GET_REMOTE_ADDR_SIZE, - &asoc, &opt_len) != 0) { + &size_of_addresses, &opt_len) != 0) { return (-1); } - /* size required is returned in 'asoc' */ - opt_len = (socklen_t)((size_t)asoc + sizeof(struct sctp_getaddresses)); + opt_len = (socklen_t)((size_t)size_of_addresses + sizeof(struct sctp_getaddresses)); addrs = calloc(1, (size_t)opt_len); if (addrs == NULL) { errno = ENOMEM; @@ -446,10 +446,10 @@ int sctp_getladdrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs) { struct sctp_getaddresses *addrs; - caddr_t lim; struct sockaddr *sa; - size_t size_of_addresses; + caddr_t lim; socklen_t opt_len; + uint32_t size_of_addresses; int cnt; if (raddrs == NULL) { @@ -457,7 +457,7 @@ sctp_getladdrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs) return (-1); } size_of_addresses = 0; - opt_len = (socklen_t)sizeof(int); + opt_len = (socklen_t)sizeof(uint32_t); if (getsockopt(sd, IPPROTO_SCTP, SCTP_GET_LOCAL_ADDR_SIZE, &size_of_addresses, &opt_len) != 0) { errno = ENOMEM; @@ -467,7 +467,7 @@ sctp_getladdrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs) errno = ENOTCONN; return (-1); } - opt_len = (socklen_t)(size_of_addresses + sizeof(struct sctp_getaddresses)); + opt_len = (socklen_t)((size_t)size_of_addresses + sizeof(struct sctp_getaddresses)); addrs = calloc(1, (size_t)opt_len); if (addrs == NULL) { errno = ENOMEM;