diff options
author | djm@openbsd.org <djm@openbsd.org> | 2020-10-18 11:32:01 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2020-10-18 23:46:29 +1100 |
commit | 816036f142ecd284c12bb3685ae316a68d2ef190 (patch) | |
tree | b964deff7f92305df67c23cc359859101798d629 /packet.c | |
parent | 9e2c4f64224f68fb84c49b5182e449f94b0dc985 (diff) |
upstream: use the new variant log macros instead of prepending
__func__ and appending ssh_err(r) manually; ok markus@
OpenBSD-Commit-ID: 1f14b80bcfa85414b2a1a6ff714fb5362687ace8
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 51 |
1 files changed, 24 insertions, 27 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.296 2020/07/05 23:59:45 djm Exp $ */ +/* $OpenBSD: packet.c,v 1.297 2020/10/18 11:32:01 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -297,13 +297,13 @@ ssh_packet_set_connection(struct ssh *ssh, int fd_in, int fd_out) int r; if (none == NULL) { - error("%s: cannot load cipher 'none'", __func__); + error_f("cannot load cipher 'none'"); return NULL; } if (ssh == NULL) ssh = ssh_alloc_session_state(); if (ssh == NULL) { - error("%s: could not allocate state", __func__); + error_f("could not allocate state"); return NULL; } state = ssh->state; @@ -313,7 +313,7 @@ ssh_packet_set_connection(struct ssh *ssh, int fd_in, int fd_out) (const u_char *)"", 0, NULL, 0, CIPHER_ENCRYPT)) != 0 || (r = cipher_init(&state->receive_context, none, (const u_char *)"", 0, NULL, 0, CIPHER_DECRYPT)) != 0) { - error("%s: cipher_init failed: %s", __func__, ssh_err(r)); + error_fr(r, "cipher_init failed"); free(ssh); /* XXX need ssh_free_session_state? */ return NULL; } @@ -897,8 +897,8 @@ ssh_set_newkeys(struct ssh *ssh, int mode) max_blocks = &state->max_blocks_in; } if (state->newkeys[mode] != NULL) { - debug("%s: rekeying %s, input %llu bytes %llu blocks, " - "output %llu bytes %llu blocks", __func__, dir, + debug_f("rekeying %s, input %llu bytes %llu blocks, " + "output %llu bytes %llu blocks", dir, (unsigned long long)state->p_read.bytes, (unsigned long long)state->p_read.blocks, (unsigned long long)state->p_send.bytes, @@ -920,7 +920,7 @@ ssh_set_newkeys(struct ssh *ssh, int mode) return r; } mac->enabled = 1; - DBG(debug("%s: cipher_init_context: %s", __func__, dir)); + DBG(debug_f("cipher_init_context: %s", dir)); cipher_free(*ccp); *ccp = NULL; if ((r = cipher_init(ccp, enc->cipher, enc->key, enc->key_len, @@ -1143,8 +1143,8 @@ ssh_packet_send2_wrapped(struct ssh *ssh) if (tmp > state->extra_pad) return SSH_ERR_INVALID_ARGUMENT; pad = state->extra_pad - tmp; - DBG(debug3("%s: adding %d (len %d padlen %d extra_pad %d)", - __func__, pad, len, padlen, state->extra_pad)); + DBG(debug3_f("adding %d (len %d padlen %d extra_pad %d)", + pad, len, padlen, state->extra_pad)); tmp = padlen; padlen += pad; /* Check whether padlen calculation overflowed */ @@ -1259,7 +1259,7 @@ ssh_packet_send2(struct ssh *ssh) */ if ((need_rekey || state->rekeying) && !ssh_packet_type_is_kex(type)) { if (need_rekey) - debug3("%s: rekex triggered", __func__); + debug3_f("rekex triggered"); debug("enqueue packet: %u", type); p = calloc(1, sizeof(*p)); if (p == NULL) @@ -1301,8 +1301,7 @@ ssh_packet_send2(struct ssh *ssh) */ if (ssh_packet_need_rekeying(ssh, sshbuf_len(p->payload))) { - debug3("%s: queued packet triggered rekex", - __func__); + debug3_f("queued packet triggered rekex"); return kex_start_rekex(ssh); } debug("dequeue packet: %u", type); @@ -1421,7 +1420,7 @@ ssh_packet_read(struct ssh *ssh) int r; if ((r = ssh_packet_read_seqnr(ssh, &type, NULL)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); + fatal_fr(r, "read"); return type; } @@ -1479,7 +1478,7 @@ ssh_packet_read_poll2_mux(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p) (r = sshbuf_get_u8(state->incoming_packet, typep)) != 0) return r; if (ssh_packet_log_type(*typep)) - debug3("%s: type %u", __func__, *typep); + debug3_f("type %u", *typep); /* sshbuf_dump(state->incoming_packet, stderr); */ /* reset for next packet */ state->packlen = 0; @@ -1710,7 +1709,7 @@ ssh_packet_read_poll2(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p) /* do we need to rekey? */ if (ssh_packet_need_rekeying(ssh, 0)) { - debug3("%s: rekex triggered", __func__); + debug3_f("rekex triggered"); if ((r = kex_start_rekex(ssh)) != 0) return r; } @@ -1836,7 +1835,7 @@ ssh_packet_send_debug(struct ssh *ssh, const char *fmt,...) (r = sshpkt_put_cstring(ssh, "")) != 0 || (r = sshpkt_send(ssh)) != 0 || (r = ssh_packet_write_wait(ssh)) != 0) - fatal("%s: %s", __func__, ssh_err(r)); + fatal_fr(r, "send DEBUG"); } void @@ -1892,15 +1891,13 @@ sshpkt_vfatal(struct ssh *ssh, int r, const char *fmt, va_list ap) default: if (vasprintf(&tag, fmt, ap) == -1) { ssh_packet_clear_keys(ssh); - logdie("%s: could not allocate failure message", - __func__); + logdie_f("could not allocate failure message"); } ssh_packet_clear_keys(ssh); errno = oerrno; - logdie("%s%sConnection %s %s: %s", + logdie_r(r, "%s%sConnection %s %s", tag != NULL ? tag : "", tag != NULL ? ": " : "", - ssh->state->server_side ? "from" : "to", - remote_id, ssh_err(r)); + ssh->state->server_side ? "from" : "to", remote_id); } } @@ -1913,7 +1910,7 @@ sshpkt_fatal(struct ssh *ssh, int r, const char *fmt, ...) sshpkt_vfatal(ssh, r, fmt, ap); /* NOTREACHED */ va_end(ap); - logdie("%s: should have exited", __func__); + logdie_f("should have exited"); } /* @@ -2078,7 +2075,7 @@ ssh_packet_set_tos(struct ssh *ssh, int tos) switch (ssh_packet_connection_af(ssh)) { # ifdef IP_TOS case AF_INET: - debug3("%s: set IP_TOS 0x%02x", __func__, tos); + debug3_f("set IP_TOS 0x%02x", tos); if (setsockopt(ssh->state->connection_in, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) == -1) error("setsockopt IP_TOS %d: %.100s:", @@ -2087,7 +2084,7 @@ ssh_packet_set_tos(struct ssh *ssh, int tos) # endif /* IP_TOS */ # ifdef IPV6_TCLASS case AF_INET6: - debug3("%s: set IPV6_TCLASS 0x%02x", __func__, tos); + debug3_f("set IPV6_TCLASS 0x%02x", tos); if (setsockopt(ssh->state->connection_in, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos)) == -1) error("setsockopt IPV6_TCLASS %d: %.100s:", @@ -2216,7 +2213,7 @@ ssh_packet_set_postauth(struct ssh *ssh) { int r; - debug("%s: called", __func__); + debug_f("called"); /* This was set in net child, but is not visible in user child */ ssh->state->after_authentication = 1; ssh->state->rekeying = 0; @@ -2472,7 +2469,7 @@ ssh_packet_set_state(struct ssh *ssh, struct sshbuf *m) if (sshbuf_len(m)) return SSH_ERR_INVALID_FORMAT; - debug3("%s: done", __func__); + debug3_f("done"); return 0; } @@ -2663,7 +2660,7 @@ ssh_packet_send_mux(struct ssh *ssh) cp = sshbuf_mutable_ptr(state->outgoing_packet); type = cp[5]; if (ssh_packet_log_type(type)) - debug3("%s: type %u", __func__, type); + debug3_f("type %u", type); /* drop everything, but the connection protocol */ if (type >= SSH2_MSG_CONNECTION_MIN && type <= SSH2_MSG_CONNECTION_MAX) { |