Browse code

auth_identity: close file in case of errors

- GH #2983

(cherry picked from commit 84cdc33429c61fe7cac91cbedf96bef560267313)

Daniel-Constantin Mierla authored on 22/12/2021 07:12:20
Showing 1 changed files
... ...
@@ -359,18 +359,22 @@ static int mod_init(void)
359 359
 	}
360 360
 	if (x509_get_notafter(&glb_imycertnotafter, pmycert)) {
361 361
 		LOG(L_ERR, "AUTH_IDENTITY:mod_init: Error getting certificate expiration date\n");
362
+		fclose(hpemfile);
362 363
 		return -13;
363 364
 	}
364 365
 	if (x509_get_notbefore(&ttmp, pmycert)) {
365 366
 		LOG(L_ERR, "AUTH_IDENTITY:mod_init: Error getting certificate validity date\n");
367
+		fclose(hpemfile);
366 368
 		return -13;
367 369
 	}
368 370
 	if ((tnow=time(0)) < 0) {
369 371
 		LOG(L_ERR, "AUTH_IDENTITY:mod_init: time error %s\n", strerror(errno));
372
+		fclose(hpemfile);
370 373
 		return -13;
371 374
 	}
372 375
 	if (tnow < ttmp || tnow > glb_imycertnotafter) {
373 376
 		LOG(L_ERR, "AUTH_IDENTITY:mod_init: Date of certificate is invalid (%s)\n", glb_sservercertpath);
377
+		fclose(hpemfile);
374 378
 		return -14;
375 379
 	}
376 380