hx509: Fix harmless TOCTOU in load_crl()
This commit is contained in:
		| @@ -600,18 +600,15 @@ load_crl(hx509_context context, const char *path, time_t *t, CRLCertificateList | |||||||
|     FILE *f; |     FILE *f; | ||||||
|     int ret; |     int ret; | ||||||
|  |  | ||||||
|  |     *t = 0; | ||||||
|     memset(crl, 0, sizeof(*crl)); |     memset(crl, 0, sizeof(*crl)); | ||||||
| 	 | 	 | ||||||
|     ret = stat(path, &sb); |  | ||||||
|     if (ret) |  | ||||||
| 	return errno; |  | ||||||
|      |  | ||||||
|     *t = sb.st_mtime; |  | ||||||
| 	 |  | ||||||
|     if ((f = fopen(path, "r")) == NULL) |     if ((f = fopen(path, "r")) == NULL) | ||||||
| 	return errno; | 	return errno; | ||||||
|  |  | ||||||
|     rk_cloexec_file(f); |     rk_cloexec_file(f); | ||||||
|  |     if (fstat(fileno(f), &sb) == 0) | ||||||
|  | 	*t = sb.st_mtime; | ||||||
|  |  | ||||||
|     ret = hx509_pem_read(context, f, crl_parser, crl); |     ret = hx509_pem_read(context, f, crl_parser, crl); | ||||||
|     fclose(f); |     fclose(f); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Nicolas Williams
					Nicolas Williams