[pcre-dev] PCRE2 SVN 463 strtoul() return value comparisons

Page principale
Supprimer ce message
Auteur: Ralf Junker
Date:  
À: pcre-dev@exim.org
Sujet: [pcre-dev] PCRE2 SVN 463 strtoul() return value comparisons
To detect string to integer conversion overflow, PCRE2 SVN 463 adds a
few lines to pcre2test.c which test if return values from strtoul() are
*greater* than UINT32_MAX or ULONG_MAX.

At least on some systems, however, these comparisons can never be true.
According to the documentation, overflow causes strtoul() to return
*exactly* these values, but not greater:

http://man7.org/linux/man-pages/man3/strtoul.3.html

As the documentation suggests, the testing should be for *equality* to
these constants. Instead, or in addition, errno may be checked against
ERANGE.

Likewise for strtol():

    http://man7.org/linux/man-pages/man3/strtol.3.html


Ralf