From d2fd406c75b53eb14bd0a4d14fdf82eb34a1c9dc Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 2 Dec 2013 09:23:31 -0800 Subject: [PATCH] Free alloc'd memory. --- configure.ac | 28 +++++++++++++++++++--------- src/protocols/ssh/ssh_client.c | 3 +++ src/protocols/ssh/ssh_key.c | 12 +++++++++++- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 0d855055..2b00be0d 100644 --- a/configure.ac +++ b/configure.ac @@ -111,6 +111,11 @@ AC_ARG_WITH(init_dir, AM_CONDITIONAL([ENABLE_INIT], [test "x${init_dir}" != "x"]) AC_SUBST(init_dir) +AC_ARG_ENABLE(ssh_agent, + [AS_HELP_STRING([--enable-ssh-agent], + [enable built-in ssh-agent]) + ],enable_ssh_agent=yes) + # # libssl # @@ -570,17 +575,22 @@ then [], [have_ssh_agent=no], [[#include ]]) - AM_CONDITIONAL([ENABLE_SSH_AGENT], [test "x${have_ssh_agent}" = "xyes"]) + AM_CONDITIONAL([ENABLE_SSH_AGENT], + [test "x${have_ssh_agent}" = "xyes" \ + -a "x${enable_ssh_agent}" = "xyes"]) - if test "x${have_ssh_agent}" = "xno" + if test "x${enable_ssh_agent}" = "xyes" then - AC_MSG_WARN([ - -------------------------------------------- - No agent forwarding found in libssh2. - Support for agent forwarding will not be built. - --------------------------------------------]) - else - AC_DEFINE([ENABLE_SSH_AGENT]) + if test "x${have_ssh_agent}" = "xno" + then + AC_MSG_ERROR([ + -------------------------------------------- + Agent forwarding support was requested but no such support was found + in libssh2. + --------------------------------------------]) + else + AC_DEFINE([ENABLE_SSH_AGENT]) + fi fi fi diff --git a/src/protocols/ssh/ssh_client.c b/src/protocols/ssh/ssh_client.c index 12a94167..a23cef29 100644 --- a/src/protocols/ssh/ssh_client.c +++ b/src/protocols/ssh/ssh_client.c @@ -235,6 +235,9 @@ static LIBSSH2_SESSION* __guac_ssh_create_session(guac_client* client) { return NULL; } + /* Free addrinfo */ + freeaddrinfo(addresses); + /* Open SSH session */ LIBSSH2_SESSION* session = libssh2_session_init_ex(NULL, NULL, NULL, client); diff --git a/src/protocols/ssh/ssh_key.c b/src/protocols/ssh/ssh_key.c index a9a78106..6940ad7e 100644 --- a/src/protocols/ssh/ssh_key.c +++ b/src/protocols/ssh/ssh_key.c @@ -127,19 +127,29 @@ ssh_key* ssh_key_alloc(char* data, int length, char* passphrase) { } /* Otherwise, unsupported type */ - else + else { + BIO_free(key_bio); return NULL; + } /* Copy private key to structure */ key->private_key_length = length; key->private_key = malloc(length); memcpy(key->private_key, data, length); + BIO_free(key_bio); return key; } void ssh_key_free(ssh_key* key) { + + /* Free key-specific data */ + if (key->type == SSH_KEY_RSA) + RSA_free(key->rsa); + else if (key->type == SSH_KEY_DSA) + DSA_free(key->dsa); + free(key->public_key); free(key); }