Re: [PATCH] afs: Replace simple_strtoul with kstrtoul in afs_parse_address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 5/30/25 5:32 PM, David Howells wrote:
Su Hui <suhui@xxxxxxxxxxxx> wrote:

kstrtoul() is better because simple_strtoul() ignores overflow which
may lead to unexpected results.
Overflow in what sense?  Are we talking about a mathematical overflow or not
checking the text beyond the end of the number?

IMO, It's meaning that  the number represented by the string exceeds the type range. Like this code:

const char str[] = "0xffffffffffffffff0000000000000001";
unsigned long res;
res = simple_strtoul(str, &p, 0); //overflow happends and  res = 0x1
err = kstrtoul(str, 0, &res); // overflow happends and res = 0x1,  err = -ERANGE

Su Hui





[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux