Avoid use of atoi in malloc
commitc923cd8c496c7f253f327361a65c737233c7ebbd
authorJoseph Myers <joseph@codesourcery.com>
Thu, 22 Dec 2022 19:37:09 +0000 (22 19:37 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Thu, 22 Dec 2022 19:37:09 +0000 (22 19:37 +0000)
treeaeb3b0d9672eb22149eb307764f981acdcbbf277
parent3c66c9600e285a42f042dd596859664b1d1372a7
Avoid use of atoi in malloc

This patch is analogous to commit
a3708cf6b0a5a68e2ed1ce3db28a03ed21d368d2.

atoi has undefined behavior on out-of-range input, which makes it
problematic to use anywhere in glibc that might be processing input
out-of-range for atoi but not specified to produce undefined behavior
for the function calling atoi.  In conjunction with the C2x strtol
changes, use of atoi in libc can also result in localplt test failures
because the redirection for strtol does not interact properly with the
libc_hidden_proto call for __isoc23_strtol for the call in the inline
atoi implementation.

In malloc/arena.c, this issue shows up for atoi calls that are only
compiled for --disable-tunables (thus with the
x86_64-linux-gnu-minimal configuration of build-many-glibcs.py, for
example).  Change those atoi calls to use strtol directly, as in the
previous such changes.

Tested for x86_64 (--disable-tunables).
malloc/arena.c