Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251205185442.GE1827@brightrain.aerifal.cx>
Date: Fri, 5 Dec 2025 13:54:42 -0500
From: Rich Felker <dalias@...c.org>
To: mamutrahal269 <levrymvc@...il.com>
Cc: musl@...ts.openwall.com, mamutrahal269 <idodo4nm@...ton.me>
Subject: Re: [PATCH] POSIX positional arg numbering (1-based) and
 multi-digit support in printf_core, raise NL_ARGMAX to 255

On Fri, Dec 05, 2025 at 11:39:45AM +0700, mamutrahal269 wrote:
> The positional argument parsing logic in printf_core was reworked: instead of only accepting single-digit
> positional indices, the code now uses getint() to read multi-digit numbers and checks for the terminating $.
> The old logic isdigit(s[1]) && s[2]=='$' was replaced with proper multi-digit parsing to support numbers
> larger than 9. Additional validation was added to reject zero as an argument index and to detect overflow
> when the index exceeds NL_ARGMAX. Similar multi-digit parsing was implemented for width and precision
> arguments using * with positional indices. Finally, NL_ARGMAX was increased from 9 to 255 in limits.h
> to match the expanded positional argument range.

What is the motivation for this change? The current choice we have is
intentional so long as the standard specifies only that it be at least
9 -- programs that depend on having more are not portable, and using a
large value like 255 increases the stack pressure of the printf-family
functions quite a bit (I believe something like 3x the current amount
on archs with 16-byte long double).

Rich

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.