Be prepared for x11_setup_display() to return NULL (for instance, if DISPLAY
authorjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Mon, 5 Jan 2009 22:53:14 +0000 (22:53 +0000)
committerjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Mon, 5 Jan 2009 22:53:14 +0000 (22:53 +0000)
has invalid contents). Simply refuse to try X forwarding in this circumstance.

git-svn-id: svn://svn.tartarus.org/sgt/putty@8390 cda61777-01e9-0310-a592-d414129be87e

ssh.c

diff --git a/ssh.c b/ssh.c
index cdf321f..92fadd0 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -4996,10 +4996,10 @@ static void do_ssh1_connection(Ssh ssh, unsigned char *in, int inlen,
        }
     }
 
-    if (ssh->cfg.x11_forward) {
+    if (ssh->cfg.x11_forward &&
+       (ssh->x11disp = x11_setup_display(ssh->cfg.x11_display,
+                                         ssh->cfg.x11_auth, &ssh->cfg))) {
        logevent("Requesting X11 forwarding");
-       ssh->x11disp = x11_setup_display(ssh->cfg.x11_display,
-                                        ssh->cfg.x11_auth, &ssh->cfg);
        /*
         * Note that while we blank the X authentication data here, we don't
         * take any special action to blank the start of an X11 channel,
@@ -8577,10 +8577,10 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen,
     /*
      * Potentially enable X11 forwarding.
      */
-    if (ssh->mainchan && !ssh->ncmode && ssh->cfg.x11_forward) {
+    if (ssh->mainchan && !ssh->ncmode && ssh->cfg.x11_forward &&
+       (ssh->x11disp = x11_setup_display(ssh->cfg.x11_display,
+                                         ssh->cfg.x11_auth, &ssh->cfg))) {
        logevent("Requesting X11 forwarding");
-       ssh->x11disp = x11_setup_display(ssh->cfg.x11_display,
-                                        ssh->cfg.x11_auth, &ssh->cfg);
        s->pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_REQUEST);
        ssh2_pkt_adduint32(s->pktout, ssh->mainchan->remoteid);
        ssh2_pkt_addstring(s->pktout, "x11-req");