Re: [PATCH v4.] nss: Use reallocarray to prevent integer overflow in getaddrinfo (bug 33977)

"Andreas K. Huettel" <[email protected]>
Newsgroups gmane.comp.lib.glibc.alpha
Organization Gentoo Linux
Message-ID <[email protected]>
OK for the release with a R-B

Am Montag, 6. Juli 2026, 17:37:32 Japanische Normalzeit schrieb Marcus Poller:
> replacing realloc by reallocarray introduces a basic overflow check.
> (old + count) might still overflow, but since the NSS backend is trusted,
> we do not consider this to be a valid case.
> ---
> v1: https://inbox.sourceware.org/libc-alpha/[email protected]/
> v2: iterated on Arjuns and Andreas review comments
> v3: re-submission to support existing tooling
> v4: moved from reallocarray to __libc_reallocarray due to a regression found by Adhemerval
> ---
>  nss/getaddrinfo.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/nss/getaddrinfo.c b/nss/getaddrinfo.c
> index 4f6ac3358a..45b7f728a1 100644
> --- a/nss/getaddrinfo.c
> +++ b/nss/getaddrinfo.c
> @@ -234,7 +234,7 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req, int family,
>        array = array->next;
>      }
>  
> -  array = realloc (res->at, (old + count) * sizeof (*array));
> +  array = __libc_reallocarray (res->at, old + count, sizeof (*array));
>  
>    if (array == NULL)
>      return false;
> 


-- 
PD Dr. Andreas K. Hüttel
[email protected]
Gentoo Linux developer 
(council, comrel, toolchain, base-system, perl, libreoffice)
https://wiki.gentoo.org/wiki/User:Dilfridge
signature.asc (application/pgp-signature, 870 B)
-----BEGIN PGP SIGNATURE-----

iQJPBAABCAA5FiEE/Rnm0xsZLuTcY+rT3CsWIV7VQSoFAmpLo8UbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwyAAoJENwrFiFe1UEqxF8QAMAVxDKeaCIygV0hvCFL
v02cSnDwQC9hM8jH5mQ8Mkf0Uj2ns1QFPLNaXR/7q/d4J2dANKBoA1Y8JX0xEohw
9FIvwJW3vb61xye57fwnChBIIVqDZkMH0eKfY5DI0dhmkBnM1ummjYsqOJVaXuso
0JjhqWOGZCLv5vs9RBP8a6b6jDCBlQVa+4AtDAg5aL/nGKnf7ggN2cuwvean+4IN
dQKeOM1bo+1MG1Fjjbtdz8fgKQBqtZLJY4a8/btWVb6NW524v/0fWvBrbOVJM2Ci
Nk0/F663dQMNSWB++EfajeX1xTaD7eqz40P2Z/llXHbI0ur7sq+j3TsrOo5JJ/Jn
UV0O2Mi9Dzf6HuMfbflP/lSzEcWe0PdfdXDEA+MtD7QXfw7lhOGOF/qM1Z0vJ3AJ
B+T5r36Jg25pVIa7RV3YUkkNZnQ62APjaocOTdGpukl4fEZI3n+obBFsOW1mtzk6
EVbc4UMGdaGKSbiPE1TwVOykHd+9au23jYMqO8MyxNvCNPC1VHXpiQ6JBcGpk1te
uP7cgW6/wn5oC4fz4t2lbpXyuazsjSxLhtUOUzRdsH67XbTDHWrkVqijcM8UbBF0
EWJjRDtBjqG47Sv4VKYJod7u5y7QVlZAa7ZX1OVn60s2hk5L3KrXJkbQqZ2cHYBc
kzuUC4kQhKbFyEvxJ/AoYmP4
=efwm
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.