aboutsummaryrefslogtreecommitdiff
path: root/src/bind.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-08-15 18:46:03 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-08-15 18:48:08 +0200
commitfe375132c33cbfd3ec6cbfdde35efe5439dbbdbb (patch)
treea81650d3a1daccbcc6d428656d3e97f032040fd4 /src/bind.c
parent2780f762474fc6593e9e859515d6845d6b37750f (diff)
downloadlibssh-fe375132c33cbfd3ec6cbfdde35efe5439dbbdbb.tar.gz
libssh-fe375132c33cbfd3ec6cbfdde35efe5439dbbdbb.tar.xz
libssh-fe375132c33cbfd3ec6cbfdde35efe5439dbbdbb.zip
bind: Add checks around key functions.
Diffstat (limited to 'src/bind.c')
-rw-r--r--src/bind.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/src/bind.c b/src/bind.c
index 8330cb0d..bc5fc187 100644
--- a/src/bind.c
+++ b/src/bind.c
@@ -386,14 +386,39 @@ int ssh_bind_accept(ssh_bind sshbind, ssh_session session) {
/* FIXME */
#if 0
- session->dsa_key = ssh_key_dup(sshbind->dsa);
- session->rsa_key = ssh_key_dup(sshbind->rsa);
+ if (sshbind->dsa) {
+ session->dsa_key = ssh_key_dup(sshbind->dsa);
+ if (session->dsa_key == NULL) {
+ ssh_set_error_oom(sshbind);
+ return SSH_ERROR;
+ }
+ }
+ if (sshbind->rsa) {
+ session->rsa_key = ssh_key_dup(sshbind->rsa);
+ if (session->rsa_key == NULL) {
+ ssh_set_error_oom(sshbind);
+ return SSH_ERROR;
+ }
+ }
#else
- dsa = ssh_key_dup(sshbind->dsa);
- rsa = ssh_key_dup(sshbind->rsa);
+ if (sshbind->dsa) {
+ dsa = ssh_key_dup(sshbind->dsa);
+ if (dsa == NULL) {
+ ssh_set_error_oom(sshbind);
+ return SSH_ERROR;
+ }
+ session->dsa_key = ssh_pki_convert_key_to_privatekey(dsa);
+ }
+
+ if (sshbind->rsa) {
+ rsa = ssh_key_dup(sshbind->rsa);
+ if (rsa == NULL) {
+ ssh_set_error_oom(sshbind);
+ return SSH_ERROR;
+ }
+ session->rsa_key = ssh_pki_convert_key_to_privatekey(rsa);
+ }
- session->dsa_key = ssh_pki_convert_key_to_privatekey(dsa);
- session->rsa_key = ssh_pki_convert_key_to_privatekey(rsa);
#endif
return SSH_OK;