From ef77e95f873f7ab21b5566e185abbf331bde7da5 Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Fri, 21 Dec 2018 21:24:22 +0100 Subject: [PATCH] Cedar/IPC.c: fix memory leak occurring when both the username and common name are not present (OpenVPN) --- src/Cedar/IPC.c | 7 +++++++ src/Cedar/Protocol.c | 1 + 2 files changed, 8 insertions(+) diff --git a/src/Cedar/IPC.c b/src/Cedar/IPC.c index 3965226d..ab913c8a 100644 --- a/src/Cedar/IPC.c +++ b/src/Cedar/IPC.c @@ -433,6 +433,13 @@ IPC *NewIPC(CEDAR *cedar, char *client_name, char *postfix, char *hubname, char { p = PackLoginWithPlainPassword(hubname, username, password); } + + if (p == NULL) + { + err = ERR_AUTH_FAILED; + goto LABEL_ERROR; + } + PackAddStr(p, "hello", client_name); PackAddInt(p, "client_ver", cedar->Version); PackAddInt(p, "client_build", cedar->Build); diff --git a/src/Cedar/Protocol.c b/src/Cedar/Protocol.c index d7609f68..df586b0e 100644 --- a/src/Cedar/Protocol.c +++ b/src/Cedar/Protocol.c @@ -7126,6 +7126,7 @@ PACK *PackLoginWithOpenVPNCertificate(char *hubname, char *username, X *x) { if (x->subject_name == NULL) { + FreePack(p); return NULL; } UniToStr(cn_username, sizeof(cn_username), x->subject_name->CommonName);