summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2012-01-16 20:34:10 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2012-01-16 20:34:10 +0000
commit0671d6b93de73b0d435dbefd63a622f9367dc620 (patch)
treef2012b3d8da5cf62567982ad71f03a9c5a63a8f2
parent37581d9f8e523a200c25366da3ac937d35b0b36a (diff)
Fix a memory leak in pkcs11_rsa_private_encrypt(), reported by Jan Klemkow.
While there, be sure to buffer_clear() between send_msg() and recv_msg(). ok markus@
-rw-r--r--usr.bin/ssh/ssh-pkcs11-client.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/ssh/ssh-pkcs11-client.c b/usr.bin/ssh/ssh-pkcs11-client.c
index 72ebbf31e66..d37ea48a887 100644
--- a/usr.bin/ssh/ssh-pkcs11-client.c
+++ b/usr.bin/ssh/ssh-pkcs11-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-pkcs11-client.c,v 1.2 2010/02/24 06:12:53 djm Exp $ */
+/* $OpenBSD: ssh-pkcs11-client.c,v 1.3 2012/01/16 20:34:09 miod Exp $ */
/*
* Copyright (c) 2010 Markus Friedl. All rights reserved.
*
@@ -117,6 +117,7 @@ pkcs11_rsa_private_encrypt(int flen, const u_char *from, u_char *to, RSA *rsa,
buffer_put_int(&msg, 0);
xfree(blob);
send_msg(&msg);
+ buffer_clear(&msg);
if (recv_msg(&msg) == SSH2_AGENT_SIGN_RESPONSE) {
signature = buffer_get_string(&msg, &slen);
@@ -126,6 +127,7 @@ pkcs11_rsa_private_encrypt(int flen, const u_char *from, u_char *to, RSA *rsa,
}
xfree(signature);
}
+ buffer_free(&msg);
return (ret);
}