Page MenuHomeFreeBSD

rtld parse_integer(): support octal and hex C notations
ClosedPublic

Authored by kib on Fri, Jun 12, 2:04 PM.

Diff Detail

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

Event Timeline

kib requested review of this revision.Fri, Jun 12, 2:04 PM
libexec/rtld-elf/rtld.c
6549

You might want to add a clause for binary (str[1] == 'b')

6571–6572

This can be greatly simplified if you just convert c to val first and then check that val < radix.

6573–6578

(you'll need <stdckdint.h>)

kib marked 2 inline comments as done.Sat, Jun 13, 12:24 AM
kib added inline comments.
libexec/rtld-elf/rtld.c
6571–6572

I did it for radixes <= 10, but it seems that for 16 it is simper, if not required, to keep existing structure.

6573–6578

Yes, it was discussed in D56151/7cfffe25da3fbc2db4bc, where the solution not utilizing non-freestanding features was proposed by dim. I prefer the current way due to that.

kib marked an inline comment as done.

Supoort binary numbers specification.
Restructure the valid character check and the digit value calculation.

kib marked an inline comment as done.Sat, Jun 13, 1:10 AM
libexec/rtld-elf/rtld.c
6571–6572

Just do the conversion as if radix == 16 first, then check radix just once.

6573–6578

<stdckdint.h> is implemented using compiler builtins and the resulting code is much simpler to reason about.

kib marked 2 inline comments as done.Sat, Jun 13, 3:59 AM
kib added inline comments.
libexec/rtld-elf/rtld.c
6573–6578

This is an implementation detail, I want rtld do be as much self-contained as possible. The used pattern to avoid overflow is well known.

kib marked an inline comment as done.

Adjust the val calculation.

This revision is now accepted and ready to land.Sat, Jun 13, 9:28 AM