aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2012-10-08 21:08:04 +0200
committerAndreas Schneider <asn@cryptomilk.org>2012-10-12 08:07:01 +0200
commit96e0301b58ad53c0cdbd2fb538284e788449ee5c (patch)
tree24f91dc325bc73deb801d5b601ca0872695e18b2
parent029d165b61d3c36c046a44d80fad6de1b2504eab (diff)
downloadlibssh-96e0301b58ad53c0cdbd2fb538284e788449ee5c.tar.gz
libssh-96e0301b58ad53c0cdbd2fb538284e788449ee5c.tar.xz
libssh-96e0301b58ad53c0cdbd2fb538284e788449ee5c.zip
dh: Don't leak 'f' on error.
Found by Coverity.
-rw-r--r--src/dh.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/dh.c b/src/dh.c
index 4b9a7695..170771d7 100644
--- a/src/dh.c
+++ b/src/dh.c
@@ -593,7 +593,7 @@ int ssh_client_dh_init(ssh_session session){
}
int ssh_client_dh_reply(ssh_session session, ssh_buffer packet){
- ssh_string f = NULL;
+ ssh_string f;
ssh_string pubkey = NULL;
ssh_string signature = NULL;
int rc;
@@ -609,13 +609,14 @@ int ssh_client_dh_reply(ssh_session session, ssh_buffer packet){
ssh_set_error(session,SSH_FATAL, "No F number in packet");
goto error;
}
- if (dh_import_f(session, f) < 0) {
+ rc = dh_import_f(session, f);
+ ssh_string_burn(f);
+ ssh_string_free(f);
+ if (rc < 0) {
ssh_set_error(session, SSH_FATAL, "Cannot import f number");
goto error;
}
- ssh_string_burn(f);
- ssh_string_free(f);
- f=NULL;
+
signature = buffer_get_ssh_string(packet);
if (signature == NULL) {
ssh_set_error(session, SSH_FATAL, "No signature in packet");