From nobody Fri Dec 10 10:26:02 2021 X-Original-To: dev-commits-src-branches@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 84D8218D3327; Fri, 10 Dec 2021 10:26:02 +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 4J9RrV27MJz4t2L; Fri, 10 Dec 2021 10:26:02 +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 1E7E918AE5; Fri, 10 Dec 2021 10:26:02 +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 1BAAQ2LO092212; Fri, 10 Dec 2021 10:26:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BAAQ2iL092211; Fri, 10 Dec 2021 10:26:02 GMT (envelope-from git) Date: Fri, 10 Dec 2021 10:26:02 GMT Message-Id: <202112101026.1BAAQ2iL092211@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: 30e6da1149bc - stable/13 - libc sctp: fix sctp_getladdrs() for 64-bit BE platforms List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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: 30e6da1149bc9cbedc71af9117fd9be766c2321c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639131962; 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=J7GKd8O9nn2G49oSHLk09NE3Qzll0rShvABrM7AIEWk=; b=TIUuQz7WAKkZU/Uh01zKAQ6YSQFF12sAyzLWkbSFw1ytzJ0F4QNE87JDrLCnTuUv7nqNSa vjad74daW4IOGLVBVwI/ZkLImg//nwq1X/oZheLTChgmn5H09/eY8pDMzpmCzZK1rseQxg fgMeSq5AlyjAy6DROpzlLH4shVvCApJop//w+vdZqEe31tzjtr6bucy4momjqchXPUuwXi T2KgMSmldkyy4onTbPAg2mychpluI8gUgU5FifBQ5zbgyZP1/b5ufvpgIx0qgG2HMXUVk9 9S0NSGr3qqc9AFO395NKFFTExMmxzkZiiFEcykhJYkmWK89wOx+2iVwSzylvNg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639131962; a=rsa-sha256; cv=none; b=BqVTiUxWpXznIG73Kt9sqQr373JdQfM0zK0cUpVFaKfJfMNDtC4le3oLf5R9QWQQdyyvry fR1Op8qjCHt4eGwxcEDABGWQ6Qm08hI+Sj7wTsHLQyqhwOz1mAVEr5pKMXqclqNjr0Hn4c GoS8vPm9N0nqNTUo2Ja3owBrfPCmN/sJJEYENJr2gqN/eDp6i8ntAR34pX1j3vL3mssyzB Zjw7vmFtAdliDvBxEzy1gp9GqvR3VmfD+kSgTKEYgMV/Fl8l61Z6fZzUiGEoG0LcfojKAT lqQBaj+yTTt1BN4AfS6unFVEQPJoa834ik64rynBugiYeZMQUfvIX8vgqlVOsQ== 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=30e6da1149bc9cbedc71af9117fd9be766c2321c commit 30e6da1149bc9cbedc71af9117fd9be766c2321c Author: Michael Tuexen AuthorDate: 2021-12-01 09:13:20 +0000 Commit: Michael Tuexen CommitDate: 2021-12-10 10:25:21 +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 (cherry picked from commit dabd8bf9145a0a7255473a482e2ccf31919c3089) --- 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;