Skip to content

Commit b1bbd30

Browse files
DanAlbertstevedlawrence
authored andcommitted
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 <[email protected]> Acked-by: Steve Lawrence <[email protected]>
1 parent 823ebc8 commit b1bbd30

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

checkpolicy/checkpolicy.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,9 @@ int main(int argc, char **argv)
456456
mlspol = 1;
457457
break;
458458
case 'c':{
459-
long int n = strtol(optarg, NULL, 10);
459+
long int n;
460+
errno = 0;
461+
n = strtol(optarg, NULL, 10);
460462
if (errno) {
461463
fprintf(stderr,
462464
"Invalid policyvers specified: %s\n",

0 commit comments

Comments
 (0)