From b1bbd3030be095b5e5c49c6f899ed8071fb05f30 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Wed, 10 Dec 2014 11:28:44 -0800 Subject: [PATCH] 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 Acked-by: Steve Lawrence --- checkpolicy/checkpolicy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/checkpolicy/checkpolicy.c b/checkpolicy/checkpolicy.c index 7699619f..61a2e899 100644 --- a/checkpolicy/checkpolicy.c +++ b/checkpolicy/checkpolicy.c @@ -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",