rtld-elf: Fix signed conversion for %hh

While char is signed on some of FreeBSD's architecutres, it's unsigned
on others. So the naked 'char' cast here needs to be 'signed char'
because in this context, we want the signed interpretation.

We don't really use %hh conversions in the run time linker, so this is
likely a nop. However, for correctness, we need this, like we did in the
kernel in fc3e5334ab. It's a nop on x86 and riscv due to defaults as
well, but does fix a bug on arm and powerpc where char is unsigned.

Suggested by: kib
Sponsored by: Netflix
This commit is contained in:
Warner Losh 2024-07-14 12:01:43 -06:00
parent 60f098f841
commit 82dfbaf7e7

View file

@ -367,7 +367,7 @@ reswitch: switch (ch = (u_char)*fmt++) {
else if (hflag)
num = (short)va_arg(ap, int);
else if (cflag)
num = (char)va_arg(ap, int);
num = (signed char)va_arg(ap, int);
else
num = va_arg(ap, int);
number: