Page MenuHomeFreeBSD

rtld: check for overflow in parse_integer()
ClosedPublic

Authored by kib on Sun, Mar 29, 11:09 PM.

Diff Detail

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

Event Timeline

kib requested review of this revision.Sun, Mar 29, 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.Mon, Mar 30, 12:21 PM
This revision was automatically updated to reflect the committed changes.