Page MenuHomeFreeBSD

rtld: check for overflow in parse_integer()
ClosedPublic

Authored by kib on Mar 29 2026, 11:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jun 11, 11:37 PM
Unknown Object (File)
Thu, May 28, 3:56 AM
Unknown Object (File)
Sun, May 24, 7:11 PM
Unknown Object (File)
May 20 2026, 8:57 PM
Unknown Object (File)
May 14 2026, 2:28 PM
Unknown Object (File)
May 14 2026, 5:34 AM
Unknown Object (File)
May 14 2026, 5:34 AM
Unknown Object (File)
May 14 2026, 1:06 AM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Mar 29 2026, 11:09 PM
libexec/rtld-elf/rtld.c
6507

Can we use the stdckint.h routines instead? There is no libc dependency there.

libexec/rtld-elf/rtld.c
6507

Can we use the stdckint.h routines instead? There is no libc dependency there.

You can also avoid the need for wrapping, and avoid unsigned ints, like so:

if (n > INT_MAX / 10)
  return (-1);
n *= 10;
if (n > INT_MAX - (c - '\0'))
  return (-1);
n += (c - '\0');

No need for stdckint.h then, either.

kib marked 2 inline comments as done.

Take Dimitry suggestion.

This revision is now accepted and ready to land.Mar 30 2026, 12:21 PM
This revision was automatically updated to reflect the committed changes.