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"])
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,18 +575,23 @@ then
[], [have_ssh_agent=no],
[[#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${enable_ssh_agent}" = "xyes"
then
if test "x${have_ssh_agent}" = "xno"
then
AC_MSG_WARN([
AC_MSG_ERROR([
--------------------------------------------
No agent forwarding found in libssh2.
Support for agent forwarding will not be built.
Agent forwarding support was requested but no such support was found
in libssh2.
--------------------------------------------])
else
AC_DEFINE([ENABLE_SSH_AGENT])
fi
fi
fi

View File

@ -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);

View File

@ -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);
}