From: djm@openbsd.org Date: Wed, 6 Aug 2025 23:44:09 +0000 (+0000) Subject: upstream: all state related to the ssh connection should live in X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fremotes%2Fanongit%2Fmaster;p=thirdparty%2Fopenssh-portable.git upstream: all state related to the ssh connection should live in struct ssh or struct packet_state; one static int escaped this rule, so move it to struct packet_state now. ok millert tb OpenBSD-Commit-ID: bd6737168bf61a836ffbdc99ee4803468db90a53 --- diff --git a/packet.c b/packet.c index 9dea2cfc5..7f67f4fcd 100644 --- a/packet.c +++ b/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.318 2025/02/18 08:02:12 djm Exp $ */ +/* $OpenBSD: packet.c,v 1.319 2025/08/06 23:44:09 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -219,6 +219,12 @@ struct session_state { /* One-off warning about weak ciphers */ int cipher_warning_done; + /* + * Disconnect in progress. Used to prevent reentry in + * ssh_packet_disconnect() + */ + int disconnecting; + /* Hook for fuzzing inbound packets */ ssh_packet_hook_fn *hook_in; void *hook_in_ctx; @@ -2064,12 +2070,12 @@ ssh_packet_disconnect(struct ssh *ssh, const char *fmt,...) { char buf[1024], remote_id[512]; va_list args; - static int disconnecting = 0; int r; - if (disconnecting) /* Guard against recursive invocations. */ + /* Guard against recursive invocations. */ + if (ssh->state->disconnecting) fatal("packet_disconnect called recursively."); - disconnecting = 1; + ssh->state->disconnecting = 1; /* * Format the message. Note that the caller must make sure the