]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
xdr: store chars consistently
authorBrooks Davis <brooks@FreeBSD.org>
Wed, 18 Jan 2023 19:13:15 +0000 (19:13 +0000)
committerBrooks Davis <brooks@FreeBSD.org>
Wed, 18 Jan 2023 19:13:15 +0000 (19:13 +0000)
commit61456545d957be9a41aa83f5178b73509a4c2a1f
tree8af331014d5a2f02b54acee0d28affaedbf28251
parent649f21d4d7a838acfa36925c717ce99df33c9c9f
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
sys/xdr/xdr.c