fix resource leaks and NULL uses found by Coverity scan.
Releng-ok by riz
This commit is contained in:
parent
602a9ede7c
commit
5091f3689d
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sign.c,v 1.3 2009/01/18 10:35:26 lukem Exp $ */
|
||||
/* $NetBSD: sign.c,v 1.4 2012/02/13 07:40:24 spz Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -66,7 +66,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: sign.c,v 1.3 2009/01/18 10:35:26 lukem Exp $");
|
||||
__RCSID("$NetBSD: sign.c,v 1.4 2012/02/13 07:40:24 spz Exp $");
|
||||
|
||||
#ifndef DISABLE_SIGN
|
||||
#include "syslogd.h"
|
||||
|
@ -258,6 +258,8 @@ sign_get_keys()
|
|||
}
|
||||
if (i2d_DSA_PUBKEY(dsa, &ptr_der_pubkey) <= 0) {
|
||||
logerror("i2d_DSA_PUBKEY() failed");
|
||||
free(der_pubkey);
|
||||
free(pubkey_b64);
|
||||
return false;
|
||||
}
|
||||
b64_ntop(der_pubkey, der_len, pubkey_b64, der_len*2);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tls.c,v 1.8 2011/10/07 10:50:01 joerg Exp $ */
|
||||
/* $NetBSD: tls.c,v 1.9 2012/02/13 07:40:24 spz Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -45,7 +45,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: tls.c,v 1.8 2011/10/07 10:50:01 joerg Exp $");
|
||||
__RCSID("$NetBSD: tls.c,v 1.9 2012/02/13 07:40:24 spz Exp $");
|
||||
|
||||
#ifndef DISABLE_TLS
|
||||
#include "syslogd.h"
|
||||
|
@ -1139,7 +1139,8 @@ parse_tls_destination(const char *p, struct filed *f, size_t linenum)
|
|||
calloc(1, sizeof(*f->f_un.f_tls.tls_conn)))
|
||||
|| !(f->f_un.f_tls.tls_conn->event = allocev())
|
||||
|| !(f->f_un.f_tls.tls_conn->retryevent = allocev())) {
|
||||
free(f->f_un.f_tls.tls_conn->event);
|
||||
if (f->f_un.f_tls.tls_conn)
|
||||
free(f->f_un.f_tls.tls_conn->event);
|
||||
free(f->f_un.f_tls.tls_conn);
|
||||
logerror("Couldn't allocate memory for TLS config");
|
||||
return false;
|
||||
|
@ -1409,7 +1410,8 @@ dispatch_socket_accept(int fd, short event, void *ev)
|
|||
if (!(conn_info = calloc(1, sizeof(*conn_info)))
|
||||
|| !(conn_info->event = allocev())
|
||||
|| !(conn_info->retryevent = allocev())) {
|
||||
free(conn_info->event);
|
||||
if (conn_info)
|
||||
free(conn_info->event);
|
||||
free(conn_info);
|
||||
SSL_free(ssl);
|
||||
close(newsock);
|
||||
|
@ -1968,10 +1970,13 @@ write_x509files(EVP_PKEY *pkey, X509 *cert,
|
|||
{
|
||||
FILE *certfile, *keyfile;
|
||||
|
||||
if (!(umask(0177),(keyfile = fopen(keyfilename, "a")))
|
||||
|| !(umask(0122),(certfile = fopen(certfilename, "a")))) {
|
||||
logerror("Unable to write to files \"%s\" and \"%s\"",
|
||||
keyfilename, certfilename);
|
||||
if (!(umask(0177),(keyfile = fopen(keyfilename, "a")))) {
|
||||
logerror("Unable to write to file \"%s\"", keyfilename);
|
||||
return false;
|
||||
}
|
||||
if (!(umask(0122),(certfile = fopen(certfilename, "a")))) {
|
||||
logerror("Unable to write to file \"%s\"", certfilename);
|
||||
(void)fclose(keyfile);
|
||||
return false;
|
||||
}
|
||||
if (!PEM_write_PrivateKey(keyfile, pkey, NULL, NULL, 0, NULL, NULL))
|
||||
|
|
Loading…
Reference in New Issue