diff options
Diffstat (limited to 'crypto/openssh/monitor_wrap.c')
| -rw-r--r-- | crypto/openssh/monitor_wrap.c | 84 |
1 files changed, 16 insertions, 68 deletions
diff --git a/crypto/openssh/monitor_wrap.c b/crypto/openssh/monitor_wrap.c index 81596a4cc66b..e2b9a2802898 100644 --- a/crypto/openssh/monitor_wrap.c +++ b/crypto/openssh/monitor_wrap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor_wrap.c,v 1.146 2026/03/02 02:40:15 djm Exp $ */ +/* $OpenBSD: monitor_wrap.c,v 1.147 2026/05/31 11:30:50 djm Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * Copyright 2002 Markus Friedl <markus@openbsd.org> @@ -302,55 +302,20 @@ mm_sshkey_sign(struct ssh *ssh, struct sshkey *key, u_char **sigp, size_t *lenp, void mm_decode_activate_server_options(struct ssh *ssh, struct sshbuf *m) { - const u_char *p; - size_t len; - u_int i; - ServerOptions *newopts; + struct sshbuf *config; int r; + u_int i; - if ((r = sshbuf_get_string_direct(m, &p, &len)) != 0) + if ((r = sshbuf_froms(m, &config)) != 0) fatal_fr(r, "parse opts"); - if (len != sizeof(*newopts)) - fatal_f("option block size mismatch"); - newopts = xcalloc(sizeof(*newopts), 1); - memcpy(newopts, p, sizeof(*newopts)); - -#define M_CP_STROPT(x) do { \ - if (newopts->x != NULL && \ - (r = sshbuf_get_cstring(m, &newopts->x, NULL)) != 0) \ - fatal_fr(r, "parse %s", #x); \ - } while (0) -#define M_CP_STRARRAYOPT(x, nx, clobber) do { \ - newopts->x = newopts->nx == 0 ? \ - NULL : xcalloc(newopts->nx, sizeof(*newopts->x)); \ - for (i = 0; i < newopts->nx; i++) { \ - if ((r = sshbuf_get_cstring(m, \ - &newopts->x[i], NULL)) != 0) \ - fatal_fr(r, "parse %s", #x); \ - } \ - } while (0) - /* See comment in servconf.h */ - COPY_MATCH_STRING_OPTS(); -#undef M_CP_STROPT -#undef M_CP_STRARRAYOPT + if ((r = deserialise_server_options(config, &options)) != 0) + fatal_fr(r, "deserialise_server_options"); + sshbuf_free(config); - copy_set_server_options(&options, newopts, 1); log_change_level(options.log_level); log_verbose_reset(); for (i = 0; i < options.num_log_verbose; i++) log_verbose_add(options.log_verbose[i]); - - /* use the macro hell to clean up too */ -#define M_CP_STROPT(x) free(newopts->x) -#define M_CP_STRARRAYOPT(x, nx, clobber) do { \ - for (i = 0; i < newopts->nx; i++) \ - free(newopts->x[i]); \ - free(newopts->x); \ - } while (0) - COPY_MATCH_STRING_OPTS(); -#undef M_CP_STROPT -#undef M_CP_STRARRAYOPT - free(newopts); } #define GETPW(b, id) \ @@ -885,22 +850,19 @@ mm_terminate(void) /* Request state information */ void -mm_get_state(struct ssh *ssh, struct include_list *includes, - struct sshbuf *conf, struct sshbuf **confdatap, +mm_get_state(struct ssh *ssh, + ServerOptions *opts, struct sshbuf **confdatap, uint64_t *timing_secretp, struct sshbuf **hostkeysp, struct sshbuf **keystatep, u_char **pw_namep, struct sshbuf **authinfop, struct sshbuf **auth_optsp) { - struct sshbuf *m, *inc; - u_char *cp; - size_t len; + struct sshbuf *m, *config; int r; - struct include_item *item; debug3_f("entering"); - if ((m = sshbuf_new()) == NULL || (inc = sshbuf_new()) == NULL) + if ((m = sshbuf_new()) == NULL || (config = sshbuf_new()) == NULL) fatal_f("sshbuf_new failed"); mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_STATE, m); @@ -909,12 +871,11 @@ mm_get_state(struct ssh *ssh, struct include_list *includes, mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_STATE, m); - if ((r = sshbuf_get_string(m, &cp, &len)) != 0 || + if ((r = sshbuf_froms(m, &config)) != 0 || (r = sshbuf_get_u64(m, timing_secretp)) != 0 || (r = sshbuf_froms(m, hostkeysp)) != 0 || (r = sshbuf_get_stringb(m, ssh->kex->server_version)) != 0 || - (r = sshbuf_get_stringb(m, ssh->kex->client_version)) != 0 || - (r = sshbuf_get_stringb(m, inc)) != 0) + (r = sshbuf_get_stringb(m, ssh->kex->client_version)) != 0) fatal_fr(r, "parse config"); /* postauth */ @@ -926,24 +887,11 @@ mm_get_state(struct ssh *ssh, struct include_list *includes, (r = sshbuf_froms(m, auth_optsp)) != 0) fatal_fr(r, "parse config postauth"); } + if ((r = deserialise_server_options(config, opts)) != 0) + fatal_fr(r, "deserialise_server_options"); - if (conf != NULL && (r = sshbuf_put(conf, cp, len))) - fatal_fr(r, "sshbuf_put"); - - while (sshbuf_len(inc) != 0) { - item = xcalloc(1, sizeof(*item)); - if ((item->contents = sshbuf_new()) == NULL) - fatal_f("sshbuf_new failed"); - if ((r = sshbuf_get_cstring(inc, &item->selector, NULL)) != 0 || - (r = sshbuf_get_cstring(inc, &item->filename, NULL)) != 0 || - (r = sshbuf_get_stringb(inc, item->contents)) != 0) - fatal_fr(r, "parse includes"); - TAILQ_INSERT_TAIL(includes, item, entry); - } - - free(cp); sshbuf_free(m); - sshbuf_free(inc); + sshbuf_free(config); debug3_f("done"); } |
