From e284402f0daf496a00e4c274802abb7972adb36c Mon Sep 17 00:00:00 2001 From: djm Date: Sun, 31 May 2026 06:14:42 +0000 Subject: [PATCH] avoid strlen(NULL) crash if an X11 channel was created before the x11-req SSH_MSG_CHANNEL_REQUEST was sent. Reported by Ben Perry via GHPR679 --- usr.bin/ssh/channels.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/usr.bin/ssh/channels.c b/usr.bin/ssh/channels.c index 712e816dadb..7c563c48fb2 100644 --- a/usr.bin/ssh/channels.c +++ b/usr.bin/ssh/channels.c @@ -1,4 +1,4 @@ -/* $OpenBSD: channels.c,v 1.459 2026/04/20 07:43:52 job Exp $ */ +/* $OpenBSD: channels.c,v 1.460 2026/05/31 06:14:42 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -1370,6 +1370,11 @@ x11_open_helper(struct ssh *ssh, struct sshbuf *b) u_char *ucp; u_int proto_len, data_len; + if (sc->x11_saved_proto == NULL) { + error("X11 forwarding opened before X11 forwarding requested"); + return -1; + } + /* Is this being called after the refusal deadline? */ if (sc->x11_refuse_time != 0 && monotime() >= sc->x11_refuse_time) {