Clear errno before call to strtol(3).

Since strtol(3) doesn't clear errno on success, anything that sets
errno prior to this call will make it look like the call failed. This
happens when built with ASAN.

Signed-off-by: Dan Albert <danalbert@google.com>
Acked-by: Steve Lawrence <slawrence@tresys.com>
This commit is contained in:
Dan Albert 2014-12-10 11:28:44 -08:00 committed by Steve Lawrence
parent 823ebc8c6b
commit b1bbd3030b

View File

@ -456,7 +456,9 @@ int main(int argc, char **argv)
mlspol = 1;
break;
case 'c':{
long int n = strtol(optarg, NULL, 10);
long int n;
errno = 0;
n = strtol(optarg, NULL, 10);
if (errno) {
fprintf(stderr,
"Invalid policyvers specified: %s\n",