|
|
Message-ID: <20261123131500.GP5716@brightrain.aerifal.cx>
Date: Mon, 23 Nov 2026 08:15:00 -0500
From: Rich Felker <dalias@...c.org>
To: Wenkai Xing <wenkaixing12@...il.com>
Cc: musl@...ts.openwall.com
Subject: Re: Bug in getdelim(): high-bit delimiters (>= 128) skipped
on slow path
On Mon, Nov 23, 2026 at 03:17:42PM +0800, Wenkai Xing wrote:
> Hello,
> We found a bug in getdelim() in musl 1.2.5 on platforms where char is
> signed (e.g., x86_64): when a valid delimiter in the range 128..255 is
> read through the slow getc_unlocked() path, it is not recognized as the
> delimiter.
> In src/stdio/getdelim.c:
> if (i+1 >= *n) *--f->rpos = c;
> else if (((*s)[i++] = c) == delim) break;
> Because the value of the assignment expression ((*s)[i++] = c) has type
> char, a byte c in 128..255 is converted to a negative signed char (e.g.,
> 200 -> -56) and then promoted to int before comparing with delim (200),
> so the comparison always fails.
Thanks. The attached patch should fix it.
View attachment "0001-getdelim-fix-signedness-error-breaking-unbuffered-de.patch" of type "text/plain" (1344 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.