resource leak (fd/mem): fclose() streams on error (Coverity NetBSD scan CID 2055)
This commit is contained in:
parent
c5f39d86c2
commit
e13d171a8e
8
dist/ntp/ntpd/ntp_crypto.c
vendored
8
dist/ntp/ntpd/ntp_crypto.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ntp_crypto.c,v 1.6 2006/03/18 08:57:25 kardel Exp $ */
|
||||
/* $NetBSD: ntp_crypto.c,v 1.7 2006/03/18 09:26:08 kardel Exp $ */
|
||||
|
||||
/*
|
||||
* ntp_crypto.c - NTP version 4 public key routines
|
||||
@ -3528,17 +3528,20 @@ crypto_cert(
|
||||
if ((ptr = fgets(linkname, MAXFILENAME, str)) == NULL) {
|
||||
msyslog(LOG_ERR, "crypto_cert: no data %s\n",
|
||||
filename);
|
||||
(void)fclose(str);
|
||||
return (NULL);
|
||||
}
|
||||
if ((ptr = strrchr(ptr, '.')) == NULL) {
|
||||
msyslog(LOG_ERR, "crypto_cert: no filestamp %s\n",
|
||||
filename);
|
||||
return (NULL);
|
||||
(void)fclose(str);
|
||||
}
|
||||
if (sscanf(++ptr, "%u", &fstamp) != 1) {
|
||||
msyslog(LOG_ERR, "crypto_cert: invalid filestamp %s\n",
|
||||
filename);
|
||||
return (NULL);
|
||||
(void)fclose(str);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -3547,6 +3550,7 @@ crypto_cert(
|
||||
if (!PEM_read(str, &name, &header, &data, &len)) {
|
||||
msyslog(LOG_ERR, "crypto_cert %s\n",
|
||||
ERR_error_string(ERR_get_error(), NULL));
|
||||
(void)fclose(str);
|
||||
return (NULL);
|
||||
}
|
||||
free(header);
|
||||
@ -3555,6 +3559,7 @@ crypto_cert(
|
||||
name);
|
||||
free(name);
|
||||
free(data);
|
||||
(void)fclose(str);
|
||||
return (NULL);
|
||||
}
|
||||
free(name);
|
||||
@ -3564,6 +3569,7 @@ crypto_cert(
|
||||
*/
|
||||
ret = cert_parse(data, len, fstamp);
|
||||
free(data);
|
||||
(void)fclose(str);
|
||||
if (ret == NULL)
|
||||
return (NULL);
|
||||
if ((ptr = strrchr(linkname, '\n')) != NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user