Skip to content

Commit

Permalink
Clear errno before call to strtol(3).
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Steve Lawrence <[email protected]>
  • Loading branch information
DanAlbert authored and stevedlawrence committed Dec 11, 2014
1 parent 823ebc8 commit b1bbd30
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion checkpolicy/checkpolicy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit b1bbd30

Please sign in to comment.