=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/mux.c,v retrieving revision 1.75 retrieving revision 1.76 diff -u -r1.75 -r1.76 --- src/usr.bin/ssh/mux.c 2018/07/31 03:07:24 1.75 +++ src/usr.bin/ssh/mux.c 2018/09/26 01:48:57 1.76 @@ -1,4 +1,4 @@ -/* $OpenBSD: mux.c,v 1.75 2018/07/31 03:07:24 djm Exp $ */ +/* $OpenBSD: mux.c,v 1.76 2018/09/26 01:48:57 djm Exp $ */ /* * Copyright (c) 2002-2008 Damien Miller * @@ -151,23 +151,23 @@ static void mux_session_confirm(struct ssh *, int, int, void *); static void mux_stdio_confirm(struct ssh *, int, int, void *); -static int process_mux_master_hello(struct ssh *, u_int, +static int mux_master_process_hello(struct ssh *, u_int, Channel *, struct sshbuf *, struct sshbuf *); -static int process_mux_new_session(struct ssh *, u_int, +static int mux_master_process_new_session(struct ssh *, u_int, Channel *, struct sshbuf *, struct sshbuf *); -static int process_mux_alive_check(struct ssh *, u_int, +static int mux_master_process_alive_check(struct ssh *, u_int, Channel *, struct sshbuf *, struct sshbuf *); -static int process_mux_terminate(struct ssh *, u_int, +static int mux_master_process_terminate(struct ssh *, u_int, Channel *, struct sshbuf *, struct sshbuf *); -static int process_mux_open_fwd(struct ssh *, u_int, +static int mux_master_process_open_fwd(struct ssh *, u_int, Channel *, struct sshbuf *, struct sshbuf *); -static int process_mux_close_fwd(struct ssh *, u_int, +static int mux_master_process_close_fwd(struct ssh *, u_int, Channel *, struct sshbuf *, struct sshbuf *); -static int process_mux_stdio_fwd(struct ssh *, u_int, +static int mux_master_process_stdio_fwd(struct ssh *, u_int, Channel *, struct sshbuf *, struct sshbuf *); -static int process_mux_stop_listening(struct ssh *, u_int, +static int mux_master_process_stop_listening(struct ssh *, u_int, Channel *, struct sshbuf *, struct sshbuf *); -static int process_mux_proxy(struct ssh *, u_int, +static int mux_master_process_proxy(struct ssh *, u_int, Channel *, struct sshbuf *, struct sshbuf *); static const struct { @@ -175,15 +175,15 @@ int (*handler)(struct ssh *, u_int, Channel *, struct sshbuf *, struct sshbuf *); } mux_master_handlers[] = { - { MUX_MSG_HELLO, process_mux_master_hello }, - { MUX_C_NEW_SESSION, process_mux_new_session }, - { MUX_C_ALIVE_CHECK, process_mux_alive_check }, - { MUX_C_TERMINATE, process_mux_terminate }, - { MUX_C_OPEN_FWD, process_mux_open_fwd }, - { MUX_C_CLOSE_FWD, process_mux_close_fwd }, - { MUX_C_NEW_STDIO_FWD, process_mux_stdio_fwd }, - { MUX_C_STOP_LISTENING, process_mux_stop_listening }, - { MUX_C_PROXY, process_mux_proxy }, + { MUX_MSG_HELLO, mux_master_process_hello }, + { MUX_C_NEW_SESSION, mux_master_process_new_session }, + { MUX_C_ALIVE_CHECK, mux_master_process_alive_check }, + { MUX_C_TERMINATE, mux_master_process_terminate }, + { MUX_C_OPEN_FWD, mux_master_process_open_fwd }, + { MUX_C_CLOSE_FWD, mux_master_process_close_fwd }, + { MUX_C_NEW_STDIO_FWD, mux_master_process_stdio_fwd }, + { MUX_C_STOP_LISTENING, mux_master_process_stop_listening }, + { MUX_C_PROXY, mux_master_process_proxy }, { 0, NULL } }; @@ -251,7 +251,7 @@ return 0; ret = snprintf(name, sizeof(name), "%.*s", (int)(cp - env), env); if (ret <= 0 || (size_t)ret >= sizeof(name)) { - error("env_permitted: name '%.100s...' too long", env); + error("%s: name '%.100s...' too long", __func__, env); return 0; } @@ -265,7 +265,7 @@ /* Mux master protocol message handlers */ static int -process_mux_master_hello(struct ssh *ssh, u_int rid, +mux_master_process_hello(struct ssh *ssh, u_int rid, Channel *c, struct sshbuf *m, struct sshbuf *reply) { u_int ver; @@ -283,8 +283,8 @@ return -1; } if (ver != SSHMUX_VER) { - error("Unsupported multiplexing protocol version %d " - "(expected %d)", ver, SSHMUX_VER); + error("%s: unsupported multiplexing protocol version %u " + "(expected %u)", __func__, ver, SSHMUX_VER); return -1; } debug2("%s: channel %d slave version %u", __func__, c->self, ver); @@ -292,14 +292,16 @@ /* No extensions are presently defined */ while (sshbuf_len(m) > 0) { char *name = NULL; + size_t value_len = 0; if ((r = sshbuf_get_cstring(m, &name, NULL)) != 0 || - (r = sshbuf_skip_string(m)) != 0) { /* value */ + (r = sshbuf_get_string_direct(m, NULL, &value_len)) != 0) { error("%s: malformed extension: %s", __func__, ssh_err(r)); return -1; } - debug2("Unrecognised slave extension \"%s\"", name); + debug2("%s: Unrecognised extension \"%s\" length %zu", + __func__, name, value_len); free(name); } state->hello_rcvd = 1; @@ -330,7 +332,7 @@ } static int -process_mux_new_session(struct ssh *ssh, u_int rid, +mux_master_process_new_session(struct ssh *ssh, u_int rid, Channel *c, struct sshbuf *m, struct sshbuf *reply) { Channel *nc; @@ -378,8 +380,8 @@ cctx->env[env_len++] = cp; cctx->env[env_len] = NULL; if (env_len > MUX_MAX_ENV_VARS) { - error(">%d environment variables received, ignoring " - "additional", MUX_MAX_ENV_VARS); + error("%s: >%d environment variables received, " + "ignoring additional", __func__, MUX_MAX_ENV_VARS); break; } } @@ -496,7 +498,7 @@ } static int -process_mux_alive_check(struct ssh *ssh, u_int rid, +mux_master_process_alive_check(struct ssh *ssh, u_int rid, Channel *c, struct sshbuf *m, struct sshbuf *reply) { int r; @@ -513,7 +515,7 @@ } static int -process_mux_terminate(struct ssh *ssh, u_int rid, +mux_master_process_terminate(struct ssh *ssh, u_int rid, Channel *c, struct sshbuf *m, struct sshbuf *reply) { debug2("%s: channel %d: terminate request", __func__, c->self); @@ -681,7 +683,7 @@ } static int -process_mux_open_fwd(struct ssh *ssh, u_int rid, +mux_master_process_open_fwd(struct ssh *ssh, u_int rid, Channel *c, struct sshbuf *m, struct sshbuf *reply) { struct Forward fwd; @@ -810,7 +812,7 @@ if (!channel_setup_local_fwd_listener(ssh, &fwd, &options.fwd_opts)) { fail: - logit("slave-requested %s failed", fwd_desc); + logit("%s: requested %s failed", __func__, fwd_desc); reply_error(reply, MUX_S_FAILURE, rid, "Port forwarding failed"); goto out; @@ -848,7 +850,7 @@ } static int -process_mux_close_fwd(struct ssh *ssh, u_int rid, +mux_master_process_close_fwd(struct ssh *ssh, u_int rid, Channel *c, struct sshbuf *m, struct sshbuf *reply) { struct Forward fwd, *found_fwd; @@ -960,7 +962,7 @@ } static int -process_mux_stdio_fwd(struct ssh *ssh, u_int rid, +mux_master_process_stdio_fwd(struct ssh *ssh, u_int rid, Channel *c, struct sshbuf *m, struct sshbuf *reply) { Channel *nc; @@ -1098,7 +1100,7 @@ } static int -process_mux_stop_listening(struct ssh *ssh, u_int rid, +mux_master_process_stop_listening(struct ssh *ssh, u_int rid, Channel *c, struct sshbuf *m, struct sshbuf *reply) { debug("%s: channel %d: stop listening", __func__, c->self); @@ -1128,7 +1130,7 @@ } static int -process_mux_proxy(struct ssh *ssh, u_int rid, +mux_master_process_proxy(struct ssh *ssh, u_int rid, Channel *c, struct sshbuf *m, struct sshbuf *reply) { int r;