d5c4431318851850f83d6a2a0c44119d0ebe4213 |
|
03-Sep-2015 |
Phil Carmody <phil@dovecot.fi> |
lib: strnum - simplify hex and oct overflow code
uintmax_t is defined to have modulo-2^n semantics, and therefore the bottom
bits of (uintmax_t) are guaranteed to be all set. Therefore the checking of
the next character read is unnecessary, as it's already done in the loop
control statement itself. (This is not true about the bottom digit base 10,
which is why the check remains in the decimal case)
Signed-off-by: Phil Carmody <phil@dovecot.fi> |
dbebc3b55a52d288d6ca3eaf0a4b49db21432477 |
|
02-Jul-2014 |
Phil Carmody <phil@dovecot.fi> |
lib: strnum - add a permissive uoff_t parser
Functions like these are so cookie-cutter, we may as well use a macro.
Note that signed helpers, if they ever appear, will need more care.
Signed-off-by: Phil Carmody <phil@dovecot.fi> |
0d73aae8da55fadb59c1fef7aa36d5e43f5f8840 |
|
02-Jul-2014 |
Phil Carmody <phil@dovecot.fi> |
lib: strnum - add permissive partial-string integer parser
Not all strings we want to parse are already strtok'ed into separate pieces.
Therefore add helpers which will read the integer, and return a pointer
past the parsed integer.
The previous helpers can be considered a special case which just follows up
with a check that the '\0' has been reached.
Showing a preference for const pointers generally, this does not try to
mimic the non-const interface of strto{l,ul,ll,ull}().
Signed-off-by: Phil Carmody <phil@dovecot.fi> |
bfdca13a8bafe19b7608e6abb13e71e93a601d0a |
|
02-Jul-2014 |
Phil Carmody <phil@dovecot.fi> |
lib: strnum - harden str_to_uintmax against overflows
The invalid number "20496382304121724020" (2^64*10/9) will be parsed as valid.
2049638230412172402 * 10 does not noticably wrap, it becomes 2049638230412172404
Do not perform operations which might wrap, and then try to detect the issue,
just compare with the known fixed bounds before doing the multiplication.
Signed-off-by: Phil Carmody <phil@dovecot.fi> |