Skip to contentSkip to conversation

simple_strtoull() - FIXME?

DISCUSSION Shuah Khan 2 participants 2 messages Mar 12, 2012

lore
Share & tools
lore

Shuah Khan

author
#0 lore raw

What's this FIXME in simple_strtoull() for? Something to be terribly concerned about and need fixing (assuming there is something that still needs fixing)

unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base)

{
        unsigned long long result;
        unsigned int rv;

        cp = _parse_integer_fixup_radix(cp, &base);
        rv = _parse_integer(cp, base, &result);
        /* FIXME */
        cp += (rv & ~KSTRTOX_OVERFLOW);

        if (endp)
                *endp = (char *)cp;

        return result;
}

EXPORT_SYMBOL(simple_strtoull);

-- Shuah

#1 lore raw
Quoted 6 lines · Shuah Khan

What's this FIXME in simple_strtoull() for? Something to be terribly concerned about and need fixing (assuming there is something that still needs fixing)

unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base)

Quoted 7 lines
{
        unsigned long long result;
        unsigned int rv;

        cp = _parse_integer_fixup_radix(cp, &base);
        rv = _parse_integer(cp, base, &result);
        /* FIXME */

git blame/show answers your question. From the commit message of 1dff46d6: lib/kstrtox: common code between kstrto*() and simple_strto*() functions:

simple_strtoull() (and scanf(), BTW) ignores integer overflow, that's a bug we currently don't have guts to fix, making KSTRTOX_OVERFLOW hack necessary.

Note that simple_strtoull and friends are now deprecated (see include/linux/kernel.h) and you should now be using the kstrto* functions instead.

~Ryan