Quote:
If the string is empty, contains only whitespace, or does not contain an initial substring that has the expected syntax for an integer in the specified base, no conversion is performed. In this case, strtol returns a value of zero and the value stored in *tailptr is the value of string.
Notice it does not say it will throw an error for this,
Quote:
If the string has valid syntax for an integer but the value is not representable because of overflow, strtol returns either LONG_MAX or LONG_MIN (see Range of Type), as appropriate for the sign of the value. It also sets errno to ERANGE to indicate there was overflow.
So in other words, feed it a bad string and errno is not changed, feed it too large a number and that is an errno error. strtol() never sets EINVAL -- you are supposed to detect invalid input using the return value and *tailptr.