From: jsg Date: Wed, 31 May 2017 04:14:34 +0000 (+0000) Subject: Fix a memory leak in pkey_add() error path. All current callers fatal X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=263b713564ff0ab0a85492533fa9f0e175915d6f;p=openbsd Fix a memory leak in pkey_add() error path. All current callers fatal if pkey_add() fails. --- 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 @@ -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);