Skip to content

Commit 38df39e

Browse files
committed
upstream: Fix cases where error codes were not correctly set
Reported by the Qualys Security Advisory team. ok markus@ OpenBSD-Commit-ID: 7bcd4ffe0fa1e27ff98d451fb9c22f5fae6e610d
1 parent 5e07dee commit 38df39e

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

krl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: krl.c,v 1.59 2023/07/17 05:22:30 djm Exp $ */
1+
/* $OpenBSD: krl.c,v 1.60 2025/02/18 08:02:48 djm Exp $ */
22
/*
33
* Copyright (c) 2012 Damien Miller <[email protected]>
44
*
@@ -674,6 +674,7 @@ revoked_certs_generate(struct revoked_certs *rc, struct sshbuf *buf)
674674
break;
675675
case KRL_SECTION_CERT_SERIAL_BITMAP:
676676
if (rs->lo - bitmap_start > INT_MAX) {
677+
r = SSH_ERR_INVALID_FORMAT;
677678
error_f("insane bitmap gap");
678679
goto out;
679680
}
@@ -1059,6 +1060,7 @@ ssh_krl_from_blob(struct sshbuf *buf, struct ssh_krl **krlp)
10591060
}
10601061

10611062
if ((krl = ssh_krl_init()) == NULL) {
1063+
r = SSH_ERR_ALLOC_FAIL;
10621064
error_f("alloc failed");
10631065
goto out;
10641066
}

ssh-agent.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,7 @@ parse_key_constraint_extension(struct sshbuf *m, char **sk_providerp,
12081208
"[email protected]") == 0) {
12091209
if (*dcsp != NULL) {
12101210
error_f("%s already set", ext_name);
1211+
r = SSH_ERR_INVALID_FORMAT;
12111212
goto out;
12121213
}
12131214
if ((r = sshbuf_froms(m, &b)) != 0) {
@@ -1217,6 +1218,7 @@ parse_key_constraint_extension(struct sshbuf *m, char **sk_providerp,
12171218
while (sshbuf_len(b) != 0) {
12181219
if (*ndcsp >= AGENT_MAX_DEST_CONSTRAINTS) {
12191220
error_f("too many %s constraints", ext_name);
1221+
r = SSH_ERR_INVALID_FORMAT;
12201222
goto out;
12211223
}
12221224
*dcsp = xrecallocarray(*dcsp, *ndcsp, *ndcsp + 1,
@@ -1234,6 +1236,7 @@ parse_key_constraint_extension(struct sshbuf *m, char **sk_providerp,
12341236
}
12351237
if (*certs != NULL) {
12361238
error_f("%s already set", ext_name);
1239+
r = SSH_ERR_INVALID_FORMAT;
12371240
goto out;
12381241
}
12391242
if ((r = sshbuf_get_u8(m, &v)) != 0 ||
@@ -1245,6 +1248,7 @@ parse_key_constraint_extension(struct sshbuf *m, char **sk_providerp,
12451248
while (sshbuf_len(b) != 0) {
12461249
if (*ncerts >= AGENT_MAX_EXT_CERTS) {
12471250
error_f("too many %s constraints", ext_name);
1251+
r = SSH_ERR_INVALID_FORMAT;
12481252
goto out;
12491253
}
12501254
*certs = xrecallocarray(*certs, *ncerts, *ncerts + 1,
@@ -1741,6 +1745,7 @@ process_ext_session_bind(SocketEntry *e)
17411745
/* record new key/sid */
17421746
if (e->nsession_ids >= AGENT_MAX_SESSION_IDS) {
17431747
error_f("too many session IDs recorded");
1748+
r = -1;
17441749
goto out;
17451750
}
17461751
e->session_ids = xrecallocarray(e->session_ids, e->nsession_ids,

ssh-sk-client.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: ssh-sk-client.c,v 1.12 2022/01/14 03:34:00 djm Exp $ */
1+
/* $OpenBSD: ssh-sk-client.c,v 1.13 2025/02/18 08:02:48 djm Exp $ */
22
/*
33
* Copyright (c) 2019 Google LLC
44
*
@@ -439,6 +439,7 @@ sshsk_load_resident(const char *provider_path, const char *device,
439439
}
440440
if ((srk = calloc(1, sizeof(*srk))) == NULL) {
441441
error_f("calloc failed");
442+
r = SSH_ERR_ALLOC_FAIL;
442443
goto out;
443444
}
444445
srk->key = key;
@@ -450,6 +451,7 @@ sshsk_load_resident(const char *provider_path, const char *device,
450451
if ((tmp = recallocarray(srks, nsrks, nsrks + 1,
451452
sizeof(*srks))) == NULL) {
452453
error_f("recallocarray keys failed");
454+
r = SSH_ERR_ALLOC_FAIL;
453455
goto out;
454456
}
455457
debug_f("srks[%zu]: %s %s uidlen %zu", nsrks,

sshconnect2.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ verify_host_key_callback(struct sshkey *hostkey, struct ssh *ssh)
9999
options.required_rsa_size)) != 0)
100100
fatal_r(r, "Bad server host key");
101101
if (verify_host_key(xxx_host, xxx_hostaddr, hostkey,
102-
xxx_conn_info) == -1)
102+
xxx_conn_info) != 0)
103103
fatal("Host key verification failed.");
104104
return 0;
105105
}
@@ -699,6 +699,7 @@ input_userauth_pk_ok(int type, u_int32_t seq, struct ssh *ssh)
699699

700700
if ((pktype = sshkey_type_from_name(pkalg)) == KEY_UNSPEC) {
701701
debug_f("server sent unknown pkalg %s", pkalg);
702+
r = SSH_ERR_INVALID_FORMAT;
702703
goto done;
703704
}
704705
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)
709710
error("input_userauth_pk_ok: type mismatch "
710711
"for decoded key (received %d, expected %d)",
711712
key->type, pktype);
713+
r = SSH_ERR_INVALID_FORMAT;
712714
goto done;
713715
}
714716

@@ -728,6 +730,7 @@ input_userauth_pk_ok(int type, u_int32_t seq, struct ssh *ssh)
728730
SSH_FP_DEFAULT);
729731
error_f("server replied with unknown key: %s %s",
730732
sshkey_type(key), fp == NULL ? "<ERROR>" : fp);
733+
r = SSH_ERR_INVALID_FORMAT;
731734
goto done;
732735
}
733736
ident = format_identity(id);

sshsig.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@ cert_filter_principals(const char *path, u_long linenum,
874874
}
875875
if ((principals = sshbuf_dup_string(nprincipals)) == NULL) {
876876
error_f("buffer error");
877+
r = SSH_ERR_ALLOC_FAIL;
877878
goto out;
878879
}
879880
/* success */

0 commit comments

Comments
 (0)