git: 82dfbaf7e7ca - main - rtld-elf: Fix signed conversion for %hh
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 14 Jul 2024 18:02:03 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=82dfbaf7e7ca1334960ee918fa1b4eb2537d444b commit 82dfbaf7e7ca1334960ee918fa1b4eb2537d444b Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2024-07-14 18:01:43 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-07-14 18:01:43 +0000 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 fc3e5334ab89. 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 --- libexec/rtld-elf/rtld_printf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/rtld-elf/rtld_printf.c b/libexec/rtld-elf/rtld_printf.c index befac1c547b7..45c0bdc00b29 100644 --- a/libexec/rtld-elf/rtld_printf.c +++ b/libexec/rtld-elf/rtld_printf.c @@ -367,7 +367,7 @@ handle_sign: 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: