summaryrefslogtreecommitdiff
path: root/usr.sbin/relayd/relayd.c
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2017-05-31 04:14:35 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2017-05-31 04:14:35 +0000
commit7577d997af014c9dc0d80a42098b53f23f154873 (patch)
tree8a390fab54aee0402b97b1877ca7df4d6b04f482 /usr.sbin/relayd/relayd.c
parent824d54a2c3b93ab15b73dc525ea91c58e1a47f30 (diff)
Fix a memory leak in pkey_add() error path. All current callers fatal
if pkey_add() fails.
Diffstat (limited to 'usr.sbin/relayd/relayd.c')
-rw-r--r--usr.sbin/relayd/relayd.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c
index a6472af10b7..7583da79efe 100644
--- a/usr.sbin/relayd/relayd.c
+++ b/usr.sbin/relayd/relayd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.c,v 1.168 2017/05/28 10:39:15 benno Exp $ */
+/* $OpenBSD: relayd.c,v 1.169 2017/05/31 04:14:34 jsg Exp $ */
/*
* Copyright (c) 2007 - 2016 Reyk Floeter <reyk@openbsd.org>
@@ -1185,8 +1185,10 @@ pkey_add(struct relayd *env, EVP_PKEY *pkey, char *hash)
ca_pkey->pkey = pkey;
if (strlcpy(ca_pkey->pkey_hash, hash, sizeof(ca_pkey->pkey_hash)) >=
- sizeof(ca_pkey->pkey_hash))
+ sizeof(ca_pkey->pkey_hash)) {
+ free(ca_pkey);
return (NULL);
+ }
TAILQ_INSERT_TAIL(env->sc_pkeys, ca_pkey, pkey_entry);