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, Aug 13, 12:58 AM
Unknown Object (File)
Tue, Aug 11, 6:06 AM
Unknown Object (File)
Mon, Aug 10, 2:09 PM
Unknown Object (File)
Mon, Aug 10, 11:25 AM
Unknown Object (File)
Sat, Aug 8, 5:18 PM
Unknown Object (File)
Sat, Aug 8, 5:05 AM
Unknown Object (File)
Tue, Aug 4, 7:39 AM
Unknown Object (File)
Mon, Aug 3, 9: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.