Sunny 2a5f48c3fd libs/libc/stdlib: fix strtoul,strtoull bugs when value outside range
Prototype:
  unsigned long strtoul(FAR const char *nptr, FAR char **endptr, int base);
  unsigned long long strtoull(FAR const char *nptr,  FAR char **endptr, int base);

If endptr is not NULL, strtoul()/strtoull() should store the address of the first
invalid character in *endptr. And if the correct value is outside the range of
representable values, {ULONG_MAX} or {ULLONG_MAX} shall be returned and errno set
to [ERANGE].

With such code:
  strtoul("34592348345343453453455645765736575865767", &endptr, 10);

It indeed returns ULONG_MAX and sets errno to ERANGE. But after strtoul
return, endptr points to "3455645765736575865767", not NULL.

Signed-off-by: Sunny <zxcvbnm37425@gmail.com>
2023-07-10 19:07:27 +03:00
..
2021-03-03 18:52:53 -08:00
2021-07-14 15:09:58 -03:00
2021-07-14 15:09:58 -03:00
2021-03-03 18:52:53 -08:00
2021-04-02 11:12:25 -05:00
2021-03-03 18:52:53 -08:00
2021-03-03 18:52:53 -08:00
2022-07-27 00:36:49 +08:00
2023-02-24 12:15:40 +08:00
2023-02-22 01:20:21 +08:00
2021-07-14 15:09:58 -03:00
2022-07-27 00:36:49 +08:00