After saving errno clear it before calls to strtol et. al.