[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/3] pki: check ssh_buffer_pack return in ssh_pki_do_sign


From 2e7295b1c234f62184985b75375a05964d82c99e Mon Sep 17 00:00:00 2001
From: Jon Simons <jon@xxxxxxxxxxxxx>
Date: Sat, 27 Sep 2014 02:07:54 -0700
Subject: [PATCH 2/3] pki: check ssh_buffer_pack return in ssh_pki_do_sign

Check the 'ssh_buffer_pack' return in ssh_pki_do_sign for the ED25519 case.

Signed-off-by: Jon Simons <jon@xxxxxxxxxxxxx>
---
 src/pki.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/pki.c b/src/pki.c
index cde803e..af472eb 100644
--- a/src/pki.c
+++ b/src/pki.c
@@ -1453,16 +1453,21 @@ ssh_string ssh_pki_do_sign(ssh_session session,
         ssh_buffer buf;
 
         buf = ssh_buffer_new();
-        if (buf == NULL){
+        if (buf == NULL) {
             ssh_string_free(session_id);
             return NULL;
         }
 
         ssh_buffer_set_secure(buf);
-        ssh_buffer_pack(buf,
-                        "SP",
-                        session_id,
-                        buffer_get_rest_len(sigbuf), buffer_get_rest(sigbuf));
+        rc = ssh_buffer_pack(buf,
+                             "SP",
+                             session_id,
+                             buffer_get_rest_len(sigbuf), buffer_get_rest(sigbuf));
+        if (rc != SSH_OK) {
+            ssh_string_free(session_id);
+            ssh_buffer_free(buf);
+            return NULL;
+        }
 
         sig = pki_do_sign(privkey,
                           ssh_buffer_get_begin(buf),
-- 
2.1.1.602.g02f248d


Archive administrator: postmaster@lists.cynapses.org