Free alloc'd memory.

This commit is contained in:
Michael Jumper 2013-12-02 09:23:31 -08:00
parent 74e1f57a1d
commit d2fd406c75
3 changed files with 33 additions and 10 deletions

View File

@ -111,6 +111,11 @@ AC_ARG_WITH(init_dir,
AM_CONDITIONAL([ENABLE_INIT], [test "x${init_dir}" != "x"]) AM_CONDITIONAL([ENABLE_INIT], [test "x${init_dir}" != "x"])
AC_SUBST(init_dir) 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 # libssl
# #
@ -570,17 +575,22 @@ then
[], [have_ssh_agent=no], [], [have_ssh_agent=no],
[[#include <libssh2.h>]]) [[#include <libssh2.h>]])
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 then
AC_MSG_WARN([ if test "x${have_ssh_agent}" = "xno"
-------------------------------------------- then
No agent forwarding found in libssh2. AC_MSG_ERROR([
Support for agent forwarding will not be built. --------------------------------------------
--------------------------------------------]) Agent forwarding support was requested but no such support was found
else in libssh2.
AC_DEFINE([ENABLE_SSH_AGENT]) --------------------------------------------])
else
AC_DEFINE([ENABLE_SSH_AGENT])
fi
fi fi
fi fi

View File

@ -235,6 +235,9 @@ static LIBSSH2_SESSION* __guac_ssh_create_session(guac_client* client) {
return NULL; return NULL;
} }
/* Free addrinfo */
freeaddrinfo(addresses);
/* Open SSH session */ /* Open SSH session */
LIBSSH2_SESSION* session = libssh2_session_init_ex(NULL, NULL, LIBSSH2_SESSION* session = libssh2_session_init_ex(NULL, NULL,
NULL, client); NULL, client);

View File

@ -127,19 +127,29 @@ ssh_key* ssh_key_alloc(char* data, int length, char* passphrase) {
} }
/* Otherwise, unsupported type */ /* Otherwise, unsupported type */
else else {
BIO_free(key_bio);
return NULL; return NULL;
}
/* Copy private key to structure */ /* Copy private key to structure */
key->private_key_length = length; key->private_key_length = length;
key->private_key = malloc(length); key->private_key = malloc(length);
memcpy(key->private_key, data, length); memcpy(key->private_key, data, length);
BIO_free(key_bio);
return key; return key;
} }
void ssh_key_free(ssh_key* 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->public_key);
free(key); free(key);
} }