3 ms·
An overflow may happen if there is an overflow for the type (e.g. reading '300' into an unsigned char). The function returns either a positive number indicatin
by victorNicollet 11y ago
An overflow may happen if there is an overflow for the type (e.g. reading '300' into an unsigned char).
The function returns either a positive number indicating the number of characters successfully read from the string (if it encountered a non-digit character) or a negative number indicating an error code.
https://lwn.net/Articles/643159/ https://lwn.net/Articles/643159/
- thomasahle 11y agoI see. And the previous code didn't have this issue?
- deleted 11y ago[deleted]
- sanderjd 11y agoHaven't read any of the relevant code, but if the new code returns a negative number representing an error, it will decrement the `str` pointer, whereas I'm guessing `simple_strtoul` leaves its `str` pointer alone on error.
- metric10 11y agoI don't know about Linux's simple_strtoul(), but the C library's strtoul(3) will return ULONG_MAX and set the string pointer to a valid location. So the old code COULD cause an issue if "io_tlb_nslabs" being equal to ULONG_MAX isn't accounted for later on, but adding -1 (0xffffffffffffffff) to a pointer (as the new code does) is far worse.