]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: Fix cases where error codes were not correctly set
authordjm@openbsd.org <djm@openbsd.org>
Tue, 18 Feb 2025 08:02:48 +0000 (08:02 +0000)
committerDamien Miller <djm@mindrot.org>
Tue, 18 Feb 2025 08:04:58 +0000 (19:04 +1100)
Reported by the Qualys Security Advisory team. ok markus@

OpenBSD-Commit-ID: 7bcd4ffe0fa1e27ff98d451fb9c22f5fae6e610d

krl.c
ssh-agent.c
ssh-sk-client.c
sshconnect2.c
sshsig.c

diff --git a/krl.c b/krl.c
index e2efdf0667a774fea80f2056b55c43607ed32174..0d0f69534182d6edcec7d9eaa13a992ec321849b 100644 (file)
--- a/krl.c
+++ b/krl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: krl.c,v 1.59 2023/07/17 05:22:30 djm Exp $ */
+/* $OpenBSD: krl.c,v 1.60 2025/02/18 08:02:48 djm Exp $ */
 /*
  * Copyright (c) 2012 Damien Miller <djm@mindrot.org>
  *
@@ -674,6 +674,7 @@ revoked_certs_generate(struct revoked_certs *rc, struct sshbuf *buf)
                        break;
                case KRL_SECTION_CERT_SERIAL_BITMAP:
                        if (rs->lo - bitmap_start > INT_MAX) {
+                               r = SSH_ERR_INVALID_FORMAT;
                                error_f("insane bitmap gap");
                                goto out;
                        }
@@ -1059,6 +1060,7 @@ ssh_krl_from_blob(struct sshbuf *buf, struct ssh_krl **krlp)
        }
 
        if ((krl = ssh_krl_init()) == NULL) {
+               r = SSH_ERR_ALLOC_FAIL;
                error_f("alloc failed");
                goto out;
        }
index d35741a8660f2cb236499eb9842a274d35f63a05..fc8e459500de17ef8bb88e203c80acb8f5454a98 100644 (file)
@@ -1208,6 +1208,7 @@ parse_key_constraint_extension(struct sshbuf *m, char **sk_providerp,
            "restrict-destination-v00@openssh.com") == 0) {
                if (*dcsp != NULL) {
                        error_f("%s already set", ext_name);
+                       r = SSH_ERR_INVALID_FORMAT;
                        goto out;
                }
                if ((r = sshbuf_froms(m, &b)) != 0) {
@@ -1217,6 +1218,7 @@ parse_key_constraint_extension(struct sshbuf *m, char **sk_providerp,
                while (sshbuf_len(b) != 0) {
                        if (*ndcsp >= AGENT_MAX_DEST_CONSTRAINTS) {
                                error_f("too many %s constraints", ext_name);
+                               r = SSH_ERR_INVALID_FORMAT;
                                goto out;
                        }
                        *dcsp = xrecallocarray(*dcsp, *ndcsp, *ndcsp + 1,
@@ -1234,6 +1236,7 @@ parse_key_constraint_extension(struct sshbuf *m, char **sk_providerp,
                }
                if (*certs != NULL) {
                        error_f("%s already set", ext_name);
+                       r = SSH_ERR_INVALID_FORMAT;
                        goto out;
                }
                if ((r = sshbuf_get_u8(m, &v)) != 0 ||
@@ -1245,6 +1248,7 @@ parse_key_constraint_extension(struct sshbuf *m, char **sk_providerp,
                while (sshbuf_len(b) != 0) {
                        if (*ncerts >= AGENT_MAX_EXT_CERTS) {
                                error_f("too many %s constraints", ext_name);
+                               r = SSH_ERR_INVALID_FORMAT;
                                goto out;
                        }
                        *certs = xrecallocarray(*certs, *ncerts, *ncerts + 1,
@@ -1741,6 +1745,7 @@ process_ext_session_bind(SocketEntry *e)
        /* record new key/sid */
        if (e->nsession_ids >= AGENT_MAX_SESSION_IDS) {
                error_f("too many session IDs recorded");
+               r = -1;
                goto out;
        }
        e->session_ids = xrecallocarray(e->session_ids, e->nsession_ids,
index 321fe53a2d9195b04ede36d32e71e7529b5af209..06fad22134fba700a08787dd3f4a1faa39f233b4 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-sk-client.c,v 1.12 2022/01/14 03:34:00 djm Exp $ */
+/* $OpenBSD: ssh-sk-client.c,v 1.13 2025/02/18 08:02:48 djm Exp $ */
 /*
  * Copyright (c) 2019 Google LLC
  *
@@ -439,6 +439,7 @@ sshsk_load_resident(const char *provider_path, const char *device,
                }
                if ((srk = calloc(1, sizeof(*srk))) == NULL) {
                        error_f("calloc failed");
+                       r = SSH_ERR_ALLOC_FAIL;
                        goto out;
                }
                srk->key = key;
@@ -450,6 +451,7 @@ sshsk_load_resident(const char *provider_path, const char *device,
                if ((tmp = recallocarray(srks, nsrks, nsrks + 1,
                    sizeof(*srks))) == NULL) {
                        error_f("recallocarray keys failed");
+                       r = SSH_ERR_ALLOC_FAIL;
                        goto out;
                }
                debug_f("srks[%zu]: %s %s uidlen %zu", nsrks,
index 11fcdea8aff18e6dc66dd1521001922df3c671b7..86f1fb08f4aed66a12a1f6c3d2d816f6b1880968 100644 (file)
@@ -99,7 +99,7 @@ verify_host_key_callback(struct sshkey *hostkey, struct ssh *ssh)
            options.required_rsa_size)) != 0)
                fatal_r(r, "Bad server host key");
        if (verify_host_key(xxx_host, xxx_hostaddr, hostkey,
-           xxx_conn_info) == -1)
+           xxx_conn_info) != 0)
                fatal("Host key verification failed.");
        return 0;
 }
@@ -699,6 +699,7 @@ input_userauth_pk_ok(int type, u_int32_t seq, struct ssh *ssh)
 
        if ((pktype = sshkey_type_from_name(pkalg)) == KEY_UNSPEC) {
                debug_f("server sent unknown pkalg %s", pkalg);
+               r = SSH_ERR_INVALID_FORMAT;
                goto done;
        }
        if ((r = sshkey_from_blob(pkblob, blen, &key)) != 0) {
@@ -709,6 +710,7 @@ input_userauth_pk_ok(int type, u_int32_t seq, struct ssh *ssh)
                error("input_userauth_pk_ok: type mismatch "
                    "for decoded key (received %d, expected %d)",
                    key->type, pktype);
+               r = SSH_ERR_INVALID_FORMAT;
                goto done;
        }
 
@@ -728,6 +730,7 @@ input_userauth_pk_ok(int type, u_int32_t seq, struct ssh *ssh)
                    SSH_FP_DEFAULT);
                error_f("server replied with unknown key: %s %s",
                    sshkey_type(key), fp == NULL ? "<ERROR>" : fp);
+               r = SSH_ERR_INVALID_FORMAT;
                goto done;
        }
        ident = format_identity(id);
index 470b286a3a982875a48a5262b7057c4710b17fed..057e1df023812363726dc111d0663cabc95612d3 100644 (file)
--- a/sshsig.c
+++ b/sshsig.c
@@ -874,6 +874,7 @@ cert_filter_principals(const char *path, u_long linenum,
        }
        if ((principals = sshbuf_dup_string(nprincipals)) == NULL) {
                error_f("buffer error");
+               r = SSH_ERR_ALLOC_FAIL;
                goto out;
        }
        /* success */