Catch more strtol() failures when using KEYRINGs

When parsing what should be a UID while resolving a KEYRING ccache
name, don't just depend on strtol() to set errno when the residual
that we pass to it can't be parsed as a number.  In addition to
checking errno, pass in and check the value of an "endptr".

[ghudson@mit.edu: simplified slightly]

(cherry picked from commit 5ac159e220297a8f62dd5edcec6f9b988b0627ea)

ticket: 7764
version_fixed: 1.12
status: resolved