From: "Anders Kaseorg" <andersk@mit.edu>
To: Herbert Xu <herbert@gondor.apana.org.au>, j.daubert@posteo.de
Cc: Dash <dash@vger.kernel.org>
Subject: Re: [PATCH] shell: Fix unsigned char promotion and truncation
Date: Wed, 11 Nov 2026 00:51:43 -0800 [thread overview]
Message-ID: <c6f2b0db-e5e3-483c-aeb2-eaabb574112a@mit.edu> (raw)
In-Reply-To: <aPeKvExPB1HluHly@gondor.apana.org.au>
On 10/21/25 06:29, Herbert Xu wrote:
> When a char is promoted to an int, it needs to be signed as otherwise
> comparisons on it may fail. Alternatively, an integer needs to be
> truncated to char before comparing it against another char.
There’s another instance of this in argstr() case CTLMBCHAR:
case CTLMBCHAR:
c = (signed char)*p--;
mb = mbnext(p);
ml = (mb >> 8) - 2;
if (flag & (QUOTES_ESC | EXP_MBCHAR)) {
length = (mb >> 8) + (mb & 0xff);
if (c == (char)CTLESC)
Since (signed char)CTLESC is negative, it never equals (char)CTLESC on
unsigned char architectures.
Reproduction:
$ uname -m
aarch64
$ dash -c 'IFS=ë; set -- ${u-a\ëb}; echo $#'
2
(Expected 1, as on x86_64.)
Anders
next prev parent reply other threads:[~2026-11-11 8:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-20 12:31 dash 0.5.13.1: problems with dash as /bin/sh on ARM64 j.daubert
2025-10-21 13:29 ` [PATCH] shell: Fix unsigned char promotion and truncation Herbert Xu
2025-10-23 11:29 ` Juergen Daubert
2026-11-11 8:51 ` Anders Kaseorg [this message]
2026-11-11 10:38 ` [PATCH] expand: Drop incorrect CTLESC cast in argstr Herbert Xu
2026-11-11 19:17 ` Anders Kaseorg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c6f2b0db-e5e3-483c-aeb2-eaabb574112a@mit.edu \
--to=andersk@mit.edu \
--cc=dash@vger.kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=j.daubert@posteo.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox