|
|
Message-ID: <20261125165246.GR5716@brightrain.aerifal.cx>
Date: Wed, 25 Nov 2026 11:52:47 -0500
From: Rich Felker <dalias@...c.org>
To: 吴尚哲 <wushangzhe26@....pku.edu.cn>
Cc: musl <musl@...ts.openwall.com>
Subject: Re: Bug in fgetspent(): signed overflow when parsing shadow
fields
On Thu, Nov 26, 2026 at 12:24:52AM +0800, 吴尚哲 wrote:
> Hello,
> We found a bug in fgetspent() in musl 1.2.5 on x86_64: when the
> last password change field in a shadow entry contains a decimal value
> outside the range of long, fgetspent() can return an entry with an
> incorrect sp_lstchg value.
>
> In src/passwd/getspnam_r.c, xatol() accumulates the digits with:
>
> for (x=0; **s-'0'<10U; ++*s) x=10*x+(**s-'0');
>
> Because x is a signed long and the loop performs no range check, the
> multiplication or addition can overflow. In our x86_64 test, the
> regular build returned an entry with sp_lstchg set to LONG_MIN. The
> UBSan trap build raised SIGILL on the same input.
Attached should fix it.
View attachment "0001-shadow-fix-integer-overflow-parsing-numeric-fields.patch" of type "text/plain" (810 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.