From nobody Wed Jan 18 19:13:26 2023 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 4NxwQZ577Nz2skbC; Wed, 18 Jan 2023 19:13:26 +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 4NxwQZ4Xyfz3rqq; Wed, 18 Jan 2023 19:13:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674069206; 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=LbH2mTk1x9sEqzXbGamBBDcOUiocOXb/C3HYvR9JZtQ=; b=XkdyrAq4P9kR0Kg3mNVJAIbWnQiwykxvbH26QsdeOBXP1D6neL59DAcdKeqhNEUKZrAdBF e3U4ylRaZRv5oJZ2/Jf0qJ0YCsnfQtnZetVBGJ9eWWuwik9saVMTkQ0qF7h+PZ0ThJnYj5 EAKNS9CrLnV0NNt/8OA6150N/YPZ7q49fhYDKYqH3uKpcHtwfhIRdR+xQc5cekx24rLmnN PqzYZsZFM5nvVF6Pjs53tqCzSGZlm++k+m5CSbrQ8e9o7VxogGo6uFs/7Ih9LVvo8DGUQZ S+7lgtBiAWuaITdzL5czpdN38i+jY42CusJ0uDieRGBJnoAweI0FXuwUu1mbRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674069206; 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=LbH2mTk1x9sEqzXbGamBBDcOUiocOXb/C3HYvR9JZtQ=; b=cAslxscjqJ8s5XDYqtdS6xpGtleFENwAVGbx2fVjnIbsJIXYv4Wp7AFqF08zyrtyZIkvZP YmriyayL3ufvRL8moZ8JSLr6neyN0KOW3lz246VdfPBZwp+i/eSsGo5EPWZwKzOK8jEnUf Z2EeSw+LMtJodlp0ZiJRvFfgHWcGBCFZMrUNlIoymmepmgabUexcx12vwqWj+FZQZ9Lcfw j57RTQPoetYN19cpGL3SKUsXv2B3+e1lhFqCxj/GbO1IrLHuCERdMF8gi52jSi9pu5Jvbs 1gWWiFrfVhG9T9S2JUrHwFYWTLFenM1sIQEPr+JdTnT+7B+61MJtm41MyT1FVw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674069206; a=rsa-sha256; cv=none; b=QfGH6Lfdwmgig3e5ZI8XObc+4VMFAYZNws8Sj2rBfY3cfzpSUWVcac0MzsCDCozcnZqm5B t/AhIrbt4cGkYSKB6yEABkMd9vUh91ULaO6aeDzb3gOEl5V1yDjeIzTlzY3ekTeAXHj8VH gj2CO5woMKaAhzYR5xVXf5V09H5Dst0DgFE2qXWFnbWTqCuByZ7rn9bMwRx9Tt29RTgnX6 3S605wvxAwyHcJP5KJheCETzLo1OECY33SL4w0DuiwfUVsTrxASPGH4yuoENftRLGzWirY d5Xw7DvNFj4STHgVn9ex+2O0XaHvzs2mOa58rEXCxs9EOkJleca5uwW/zzM7gA== 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 4NxwQZ3ZwPzMhm; Wed, 18 Jan 2023 19:13:26 +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 30IJDQhW082143; Wed, 18 Jan 2023 19:13:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30IJDQ10082142; Wed, 18 Jan 2023 19:13:26 GMT (envelope-from git) Date: Wed, 18 Jan 2023 19:13:26 GMT Message-Id: <202301181913.30IJDQ10082142@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Brooks Davis Subject: git: 61456545d957 - stable/13 - xdr: store chars consistently 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: brooks X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 61456545d957be9a41aa83f5178b73509a4c2a1f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=61456545d957be9a41aa83f5178b73509a4c2a1f commit 61456545d957be9a41aa83f5178b73509a4c2a1f Author: Brooks Davis AuthorDate: 2023-01-18 19:13:15 +0000 Commit: Brooks Davis CommitDate: 2023-01-18 19:13:15 +0000 xdr: store chars consistently Cast char's through unsigned char before storing as an integer in xdr_char(), this ensures that the encoded form is consistently not sign-extended following Open Solaris's example. Prior to this change, platforms with signed chars would sign extend values with the high bit set but ones with unsigned chars would not so 0xff would be stored as 0x000000ff on unsigned char platforms and 0xffffffff on signed char platforms. Decoding has the same result for either form so this is a largely cosmetic change, but it seems best to produce consistent output. For more discussion, see https://github.com/openzfs/zfs/issues/14173 Reviewed by: mav, imp Differential Revision: https://reviews.freebsd.org/D37992 (cherry picked from commit a872c37054172f3f7a03aef263ca5886a749771f) --- lib/libc/xdr/xdr.c | 8 ++++---- sys/xdr/xdr.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/libc/xdr/xdr.c b/lib/libc/xdr/xdr.c index fcf4e9029074..48b4cdbecd02 100644 --- a/lib/libc/xdr/xdr.c +++ b/lib/libc/xdr/xdr.c @@ -429,13 +429,13 @@ xdr_uint16_t(XDR *xdrs, uint16_t *u_int16_p) bool_t xdr_char(XDR *xdrs, char *cp) { - int i; + u_int i; - i = (*cp); - if (!xdr_int(xdrs, &i)) { + i = *((unsigned char *)cp); + if (!xdr_u_int(xdrs, &i)) { return (FALSE); } - *cp = i; + *((unsigned char *)cp) = i; return (TRUE); } diff --git a/sys/xdr/xdr.c b/sys/xdr/xdr.c index 0a0bf3f66744..b57eb7d66ef4 100644 --- a/sys/xdr/xdr.c +++ b/sys/xdr/xdr.c @@ -358,13 +358,13 @@ xdr_uint16_t(XDR *xdrs, uint16_t *uint16_p) bool_t xdr_char(XDR *xdrs, char *cp) { - int i; + u_int i; - i = (*cp); - if (!xdr_int(xdrs, &i)) { + i = *((unsigned char *)cp); + if (!xdr_u_int(xdrs, &i)) { return (FALSE); } - *cp = i; + *((unsigned char *)cp) = i; return (TRUE); }