Use strtoul instead of atoi so that overflow can be detected. (cherry picked from commit 5adda61f)
mentioned in commit cdf5ee72