Browse Source

PuTTY snapshot 2e7ced64 (Give BPPs a Frontend, so they can do their own logging - 2018-10-07)

Source commit: f27fdc3ac77d1ee38d54f7fd511fce5b481cc70f
Martin Prikryl 6 years ago
parent
commit
10149b5d57

+ 5 - 4
source/putty/WINDOWS/winucs.c

@@ -1157,7 +1157,7 @@ void get_unitab(int codepage, wchar_t * unitab, int ftype)
 }
 
 int wc_to_mb(int codepage, int flags, const wchar_t *wcstr, int wclen,
-	     char *mbstr, int mblen, const char *defchr, int *defused,
+	     char *mbstr, int mblen, const char *defchr,
 	     struct unicode_data *ucsdata)
 {
     char *p;
@@ -1180,7 +1180,6 @@ int wc_to_mb(int codepage, int flags, const wchar_t *wcstr, int wclen,
 		int j;
 		for (j = 0; defchr[j]; j++)
 		    *p++ = defchr[j];
-		if (defused) *defused = 1;
 	    }
 #if 1
 	    else
@@ -1189,9 +1188,11 @@ int wc_to_mb(int codepage, int flags, const wchar_t *wcstr, int wclen,
 	    assert(p - mbstr < mblen);
 	}
 	return p - mbstr;
-    } else
+    } else {
+        int defused;
 	return WideCharToMultiByte(codepage, flags, wcstr, wclen,
-				   mbstr, mblen, defchr, defused);
+				   mbstr, mblen, defchr, &defused);
+    }
 }
 
 int mb_to_wc(int codepage, int flags, const char *mbstr, int mblen,

+ 1 - 1
source/putty/putty.h

@@ -1294,7 +1294,7 @@ int is_dbcs_leadbyte(int codepage, char byte);
 int mb_to_wc(int codepage, int flags, const char *mbstr, int mblen,
 	     wchar_t *wcstr, int wclen);
 int wc_to_mb(int codepage, int flags, const wchar_t *wcstr, int wclen,
-	     char *mbstr, int mblen, const char *defchr, int *defused,
+	     char *mbstr, int mblen, const char *defchr,
 	     struct unicode_data *ucsdata);
 wchar_t xlat_uskbd2cyrllic(int ch);
 int check_compose(int first, int second);

+ 3 - 3
source/putty/ssh.c

@@ -172,7 +172,7 @@ static void ssh_got_ssh_version(struct ssh_version_receiver *rcv,
             int is_simple =
                 (conf_get_int(ssh->conf, CONF_ssh_simple) && !ssh->connshare);
 
-            ssh->bpp = ssh2_bpp_new(&ssh->stats);
+            ssh->bpp = ssh2_bpp_new(ssh->frontend, &ssh->stats);
             ssh_connect_bpp(ssh);
 
 #ifndef NO_GSSAPI
@@ -247,7 +247,7 @@ static void ssh_got_ssh_version(struct ssh_version_receiver *rcv,
 
         } else {
 
-            ssh->bpp = ssh1_bpp_new();
+            ssh->bpp = ssh1_bpp_new(ssh->frontend);
             ssh_connect_bpp(ssh);
 
             connection_layer = ssh1_connection_new(ssh, ssh->conf, &ssh->cl);
@@ -260,7 +260,7 @@ static void ssh_got_ssh_version(struct ssh_version_receiver *rcv,
         }
 
     } else {
-        ssh->bpp = ssh2_bare_bpp_new();
+        ssh->bpp = ssh2_bare_bpp_new(ssh->frontend);
         ssh_connect_bpp(ssh);
 
         connection_layer = ssh2_connection_new(

+ 22 - 13
source/putty/ssh.h

@@ -90,12 +90,12 @@ typedef struct PacketQueueBase {
 
 typedef struct PktInQueue {
     PacketQueueBase pqb;
-    PktIn *(*get)(PacketQueueBase *, int pop);
+    PktIn *(*after)(PacketQueueBase *, PacketQueueNode *prev, int pop);
 } PktInQueue;
 
 typedef struct PktOutQueue {
     PacketQueueBase pqb;
-    PktOut *(*get)(PacketQueueBase *, int pop);
+    PktOut *(*after)(PacketQueueBase *, PacketQueueNode *prev, int pop);
 } PktOutQueue;
 
 void pq_base_push(PacketQueueBase *pqb, PacketQueueNode *node);
@@ -108,21 +108,24 @@ void pq_out_init(PktOutQueue *pq);
 void pq_in_clear(PktInQueue *pq);
 void pq_out_clear(PktOutQueue *pq);
 
-#define pq_push(pq, pkt)                                \
-    TYPECHECK((pq)->get(&(pq)->pqb, FALSE) == pkt,      \
+#define pq_push(pq, pkt)                                        \
+    TYPECHECK((pq)->after(&(pq)->pqb, NULL, FALSE) == pkt,      \
               pq_base_push(&(pq)->pqb, &(pkt)->qnode))
 #define pq_push_front(pq, pkt)                                  \
-    TYPECHECK((pq)->get(&(pq)->pqb, FALSE) == pkt,              \
+    TYPECHECK((pq)->after(&(pq)->pqb, NULL, FALSE) == pkt,      \
               pq_base_push_front(&(pq)->pqb, &(pkt)->qnode))
-#define pq_peek(pq) ((pq)->get(&(pq)->pqb, FALSE))
-#define pq_pop(pq) ((pq)->get(&(pq)->pqb, TRUE))
-#define pq_concatenate(dst, q1, q2)                                      \
-    TYPECHECK((q1)->get(&(q1)->pqb, FALSE) ==                           \
-              (dst)->get(&(dst)->pqb, FALSE) &&                         \
-              (q2)->get(&(q2)->pqb, FALSE) ==                           \
-              (dst)->get(&(dst)->pqb, FALSE),                           \
+#define pq_peek(pq) ((pq)->after(&(pq)->pqb, &(pq)->pqb.end, FALSE))
+#define pq_pop(pq) ((pq)->after(&(pq)->pqb, &(pq)->pqb.end, TRUE))
+#define pq_concatenate(dst, q1, q2)                                     \
+    TYPECHECK((q1)->after(&(q1)->pqb, NULL, FALSE) ==                   \
+              (dst)->after(&(dst)->pqb, NULL, FALSE) &&                 \
+              (q2)->after(&(q2)->pqb, NULL, FALSE) ==                   \
+              (dst)->after(&(dst)->pqb, NULL, FALSE),                   \
               pq_base_concatenate(&(dst)->pqb, &(q1)->pqb, &(q2)->pqb))
 
+#define pq_first(pq) pq_peek(pq)
+#define pq_next(pq, pkt) ((pq)->after(&(pq)->pqb, &(pkt)->qnode, FALSE))
+
 /*
  * Packet type contexts, so that ssh2_pkt_type can correctly decode
  * the ambiguous type numbers back into the correct type strings.
@@ -762,10 +765,12 @@ struct ssh_compression_alg {
 #define ssh_compressor_free(comp) ((comp)->vt->compress_free(comp))
 #define ssh_compressor_compress(comp, in, inlen, out, outlen, minlen) \
     ((comp)->vt->compress(comp, in, inlen, out, outlen, minlen))
+#define ssh_compressor_alg(comp) ((comp)->vt)
 #define ssh_decompressor_new(alg) ((alg)->decompress_new())
 #define ssh_decompressor_free(comp) ((comp)->vt->decompress_free(comp))
 #define ssh_decompressor_decompress(comp, in, inlen, out, outlen) \
     ((comp)->vt->decompress(comp, in, inlen, out, outlen))
+#define ssh_decompressor_alg(comp) ((comp)->vt)
 
 struct ssh2_userkey {
     ssh_key *key;                      /* the key itself */
@@ -921,8 +926,12 @@ int x11_authcmp(void *av, void *bv); /* for putting X11FakeAuth in a tree234 */
  * the supplied authtype parameter configures the preferred
  * authorisation protocol to use at the remote end. The local auth
  * details are looked up by calling platform_get_x11_auth.
+ *
+ * If the returned pointer is NULL, then *error_msg will contain a
+ * dynamically allocated error message string.
  */
-extern struct X11Display *x11_setup_display(const char *display, Conf *);
+extern struct X11Display *x11_setup_display(const char *display, Conf *,
+                                            char **error_msg);
 void x11_free_display(struct X11Display *disp);
 struct X11FakeAuth *x11_invent_fake_auth(tree234 *t, int authtype);
 void x11_free_fake_auth(struct X11FakeAuth *auth);

+ 9 - 1
source/putty/ssh1bpp.c

@@ -43,11 +43,12 @@ static const struct BinaryPacketProtocolVtable ssh1_bpp_vtable = {
     ssh1_bpp_queue_disconnect,
 };
 
-BinaryPacketProtocol *ssh1_bpp_new(void)
+BinaryPacketProtocol *ssh1_bpp_new(Frontend *frontend)
 {
     struct ssh1_bpp_state *s = snew(struct ssh1_bpp_state);
     memset(s, 0, sizeof(*s));
     s->bpp.vt = &ssh1_bpp_vtable;
+    s->bpp.frontend = frontend;
     ssh_bpp_common_setup(&s->bpp);
     return &s->bpp;
 }
@@ -67,6 +68,9 @@ static void ssh1_bpp_free(BinaryPacketProtocol *bpp)
     sfree(s);
 }
 
+#define bpp_logevent(printf_args) \
+    logevent_and_free(s->bpp.frontend, dupprintf printf_args)
+
 void ssh1_bpp_new_cipher(BinaryPacketProtocol *bpp,
                          const struct ssh1_cipheralg *cipher,
                          const void *session_key)
@@ -83,6 +87,8 @@ void ssh1_bpp_new_cipher(BinaryPacketProtocol *bpp,
 
         assert(!s->crcda_ctx);
         s->crcda_ctx = crcda_make_context();
+
+        bpp_logevent(("Initialised %s encryption", cipher->text_name));
     }
 }
 
@@ -223,6 +229,8 @@ static void ssh1_bpp_handle_input(BinaryPacketProtocol *bpp)
 
                         s->compctx = ssh_compressor_new(&ssh_zlib);
                         s->decompctx = ssh_decompressor_new(&ssh_zlib);
+
+                        bpp_logevent(("Started zlib (RFC1950) compression"));
                     }
 
                     /*

+ 5 - 3
source/putty/ssh1connection.c

@@ -649,13 +649,15 @@ static void ssh1_connection_process_queue(PacketProtocolLayer *ppl)
     }
 
     if (conf_get_int(s->conf, CONF_x11_forward)) {
+        char *x11_setup_err;
+
         s->x11disp =
             x11_setup_display(conf_get_str(s->conf, CONF_x11_display),
-                              s->conf);
+                              s->conf, &x11_setup_err);
         if (!s->x11disp) {
-            /* FIXME: return an error message from x11_setup_display */
             ppl_logevent(("X11 forwarding not enabled: unable to"
-                          " initialise X display"));
+                          " initialise X display: %s", x11_setup_err));
+            sfree(x11_setup_err);
         } else {
             s->x11auth = x11_invent_fake_auth
                 (s->x11authtree, conf_get_int(s->conf, CONF_x11_auth));

+ 0 - 2
source/putty/ssh1login.c

@@ -406,7 +406,6 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
             (s->cipher_type == SSH_CIPHER_BLOWFISH ? &ssh1_blowfish :
              s->cipher_type == SSH_CIPHER_DES ? &ssh1_des : &ssh1_3des);
         ssh1_bpp_new_cipher(s->ppl.bpp, cipher, s->session_key);
-        ppl_logevent(("Initialised %s encryption", cipher->text_name));
     }
 
     if (s->servkey.modulus) {
@@ -1114,7 +1113,6 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
              * easiest way to avoid race conditions if other packets
              * cross in transit.)
              */
-            ppl_logevent(("Started zlib (RFC1950) compression"));
 	} else if (pktin->type == SSH1_SMSG_FAILURE) {
             ppl_logevent(("Server refused to enable compression"));
 	    ppl_printf(("Server refused to compress\r\n"));

+ 2 - 1
source/putty/ssh2bpp-bare.c

@@ -33,11 +33,12 @@ static const struct BinaryPacketProtocolVtable ssh2_bare_bpp_vtable = {
     ssh2_bpp_queue_disconnect, /* in sshcommon.c */
 };
 
-BinaryPacketProtocol *ssh2_bare_bpp_new(void)
+BinaryPacketProtocol *ssh2_bare_bpp_new(Frontend *frontend)
 {
     struct ssh2_bare_bpp_state *s = snew(struct ssh2_bare_bpp_state);
     memset(s, 0, sizeof(*s));
     s->bpp.vt = &ssh2_bare_bpp_vtable;
+    s->bpp.frontend = frontend;
     ssh_bpp_common_setup(&s->bpp);
     return &s->bpp;
 }

+ 33 - 1
source/putty/ssh2bpp.c

@@ -51,11 +51,13 @@ static const struct BinaryPacketProtocolVtable ssh2_bpp_vtable = {
     ssh2_bpp_queue_disconnect, /* in sshcommon.c */
 };
 
-BinaryPacketProtocol *ssh2_bpp_new(struct DataTransferStats *stats)
+BinaryPacketProtocol *ssh2_bpp_new(
+    Frontend *frontend, struct DataTransferStats *stats)
 {
     struct ssh2_bpp_state *s = snew(struct ssh2_bpp_state);
     memset(s, 0, sizeof(*s));
     s->bpp.vt = &ssh2_bpp_vtable;
+    s->bpp.frontend = frontend;
     s->stats = stats;
     ssh_bpp_common_setup(&s->bpp);
     return &s->bpp;
@@ -81,6 +83,9 @@ static void ssh2_bpp_free(BinaryPacketProtocol *bpp)
     sfree(s);
 }
 
+#define bpp_logevent(printf_args) \
+    logevent_and_free(s->bpp.frontend, dupprintf printf_args)
+
 void ssh2_bpp_new_outgoing_crypto(
     BinaryPacketProtocol *bpp,
     const struct ssh2_cipheralg *cipher, const void *ckey, const void *iv,
@@ -106,6 +111,9 @@ void ssh2_bpp_new_outgoing_crypto(
         s->cbc_ignore_workaround = (
             (ssh2_cipher_alg(s->out.cipher)->flags & SSH_CIPHER_IS_CBC) &&
             !(s->bpp.remote_bugs & BUG_CHOKES_ON_SSH2_IGNORE));
+
+        bpp_logevent(("Initialised %.200s client->server encryption",
+                      ssh2_cipher_alg(s->out.cipher)->text_name));
     } else {
         s->out.cipher = NULL;
         s->cbc_ignore_workaround = FALSE;
@@ -114,6 +122,14 @@ void ssh2_bpp_new_outgoing_crypto(
     if (mac) {
         s->out.mac = ssh2_mac_new(mac, s->out.cipher);
         mac->setkey(s->out.mac, mac_key);
+
+        bpp_logevent(("Initialised %.200s client->server"
+                      " MAC algorithm%s%s",
+                      ssh2_mac_alg(s->out.mac)->text_name,
+                      etm_mode ? " (in ETM mode)" : "",
+                      (s->out.cipher &&
+                       ssh2_cipher_alg(s->out.cipher)->required_mac ?
+                       " (required by cipher)" : "")));
     } else {
         s->out.mac = NULL;
     }
@@ -122,6 +138,9 @@ void ssh2_bpp_new_outgoing_crypto(
      * indicated by ssh_comp_none. But this setup call may return a
      * null out_comp. */
     s->out_comp = ssh_compressor_new(compression);
+    if (s->out_comp)
+        bpp_logevent(("Initialised %s compression",
+                      ssh_compressor_alg(s->out_comp)->text_name));
 }
 
 void ssh2_bpp_new_incoming_crypto(
@@ -145,6 +164,9 @@ void ssh2_bpp_new_incoming_crypto(
         s->in.cipher = ssh2_cipher_new(cipher);
         ssh2_cipher_setkey(s->in.cipher, ckey);
         ssh2_cipher_setiv(s->in.cipher, iv);
+
+        bpp_logevent(("Initialised %.200s server->client encryption",
+                      ssh2_cipher_alg(s->in.cipher)->text_name));
     } else {
         s->in.cipher = NULL;
     }
@@ -152,6 +174,13 @@ void ssh2_bpp_new_incoming_crypto(
     if (mac) {
         s->in.mac = ssh2_mac_new(mac, s->in.cipher);
         mac->setkey(s->in.mac, mac_key);
+
+        bpp_logevent(("Initialised %.200s server->client MAC algorithm%s%s",
+                      ssh2_mac_alg(s->in.mac)->text_name,
+                      etm_mode ? " (in ETM mode)" : "",
+                      (s->in.cipher &&
+                       ssh2_cipher_alg(s->in.cipher)->required_mac ?
+                       " (required by cipher)" : "")));
     } else {
         s->in.mac = NULL;
     }
@@ -160,6 +189,9 @@ void ssh2_bpp_new_incoming_crypto(
      * indicated by ssh_comp_none. But this setup call may return a
      * null in_decomp. */
     s->in_decomp = ssh_decompressor_new(compression);
+    if (s->in_decomp)
+        bpp_logevent(("Initialised %s decompression",
+                      ssh_decompressor_alg(s->in_decomp)->text_name));
 
     /* Clear the pending_newkeys flag, so that handle_input below will
      * start consuming the input data again. */

+ 5 - 3
source/putty/ssh2connection.c

@@ -1249,12 +1249,14 @@ static void ssh2_connection_process_queue(PacketProtocolLayer *ppl)
 
 	/* Potentially enable X11 forwarding. */
 	if (conf_get_int(s->conf, CONF_x11_forward)) {
+            char *x11_setup_err;
             s->x11disp = x11_setup_display(
-                conf_get_str(s->conf, CONF_x11_display), s->conf);
+                conf_get_str(s->conf, CONF_x11_display),
+                s->conf, &x11_setup_err);
             if (!s->x11disp) {
-                /* FIXME: return an error message from x11_setup_display */
                 ppl_logevent(("X11 forwarding not enabled: unable to"
-                              " initialise X display"));
+                              " initialise X display: %s", x11_setup_err));
+                sfree(x11_setup_err);
             } else {
                 s->x11auth = x11_invent_fake_auth(
                     s->x11authtree, conf_get_int(s->conf, CONF_x11_auth));

+ 0 - 27
source/putty/ssh2transport.c

@@ -2153,20 +2153,6 @@ static void ssh2_transport_process_queue(PacketProtocolLayer *ppl)
         strbuf_free(mac_key);
     }
 
-    if (s->out.cipher)
-        ppl_logevent(("Initialised %.200s client->server encryption",
-                      s->out.cipher->text_name));
-    if (s->out.mac)
-        ppl_logevent(("Initialised %.200s client->server"
-                      " MAC algorithm%s%s",
-                      s->out.mac->text_name,
-                      s->out.etm_mode ? " (in ETM mode)" : "",
-                      (s->out.cipher->required_mac ?
-                       " (required by cipher)" : "")));
-    if (s->out.comp->text_name)
-        ppl_logevent(("Initialised %s compression",
-                      s->out.comp->text_name));
-
     /*
      * Now our end of the key exchange is complete, we can send all
      * our queued higher-layer packets. Transfer the whole of the next
@@ -2222,19 +2208,6 @@ static void ssh2_transport_process_queue(PacketProtocolLayer *ppl)
         strbuf_free(mac_key);
     }
 
-    if (s->in.cipher)
-        ppl_logevent(("Initialised %.200s server->client encryption",
-                      s->in.cipher->text_name));
-    if (s->in.mac)
-        ppl_logevent(("Initialised %.200s server->client MAC algorithm%s%s",
-                      s->in.mac->text_name,
-                      s->in.etm_mode ? " (in ETM mode)" : "",
-                      (s->in.cipher->required_mac ?
-                       " (required by cipher)" : "")));
-    if (s->in.comp->text_name)
-        ppl_logevent(("Initialised %s decompression",
-                      s->in.comp->text_name));
-
     /*
      * Free shared secret.
      */

+ 5 - 3
source/putty/sshbpp.h

@@ -23,6 +23,7 @@ struct BinaryPacketProtocol {
     PacketLogSettings *pls;
     LogContext *logctx;
     Ssh *ssh;
+    Frontend *frontend;
 
     /* ic_in_raw is filled in by the BPP (probably by calling
      * ssh_bpp_common_setup). The BPP's owner triggers it when data is
@@ -52,7 +53,7 @@ struct BinaryPacketProtocol {
  * does centralised parts of the freeing too. */
 void ssh_bpp_free(BinaryPacketProtocol *bpp);
 
-BinaryPacketProtocol *ssh1_bpp_new(void);
+BinaryPacketProtocol *ssh1_bpp_new(Frontend *frontend);
 void ssh1_bpp_new_cipher(BinaryPacketProtocol *bpp,
                          const struct ssh1_cipheralg *cipher,
                          const void *session_key);
@@ -96,7 +97,8 @@ struct DataTransferStats {
      ((stats)->direction.running = FALSE, TRUE) :       \
      ((stats)->direction.remaining -= (size), FALSE))
 
-BinaryPacketProtocol *ssh2_bpp_new(struct DataTransferStats *stats);
+BinaryPacketProtocol *ssh2_bpp_new(
+    Frontend *frontend, struct DataTransferStats *stats);
 void ssh2_bpp_new_outgoing_crypto(
     BinaryPacketProtocol *bpp,
     const struct ssh2_cipheralg *cipher, const void *ckey, const void *iv,
@@ -108,7 +110,7 @@ void ssh2_bpp_new_incoming_crypto(
     const struct ssh2_macalg *mac, int etm_mode, const void *mac_key,
     const struct ssh_compression_alg *compression);
 
-BinaryPacketProtocol *ssh2_bare_bpp_new(void);
+BinaryPacketProtocol *ssh2_bare_bpp_new(Frontend *frontend);
 
 /*
  * The initial code to handle the SSH version exchange is also

+ 8 - 6
source/putty/sshcommon.c

@@ -71,9 +71,10 @@ static IdempotentCallback ic_pktin_free = {
     pktin_free_queue_callback, NULL, FALSE
 };
 
-static PktIn *pq_in_get(PacketQueueBase *pqb, int pop)
+static PktIn *pq_in_after(PacketQueueBase *pqb,
+                          PacketQueueNode *prev, int pop)
 {
-    PacketQueueNode *node = pqb->end.next;
+    PacketQueueNode *node = prev->next;
     if (node == &pqb->end)
         return NULL;
 
@@ -92,9 +93,10 @@ static PktIn *pq_in_get(PacketQueueBase *pqb, int pop)
     return container_of(node, PktIn, qnode);
 }
 
-static PktOut *pq_out_get(PacketQueueBase *pqb, int pop)
+static PktOut *pq_out_after(PacketQueueBase *pqb,
+                            PacketQueueNode *prev, int pop)
 {
-    PacketQueueNode *node = pqb->end.next;
+    PacketQueueNode *node = prev->next;
     if (node == &pqb->end)
         return NULL;
 
@@ -111,14 +113,14 @@ void pq_in_init(PktInQueue *pq)
 {
     pq->pqb.ic = NULL;
     pq->pqb.end.next = pq->pqb.end.prev = &pq->pqb.end;
-    pq->get = pq_in_get;
+    pq->after = pq_in_after;
 }
 
 void pq_out_init(PktOutQueue *pq)
 {
     pq->pqb.ic = NULL;
     pq->pqb.end.next = pq->pqb.end.prev = &pq->pqb.end;
-    pq->get = pq_out_get;
+    pq->after = pq_out_after;
 }
 
 void pq_in_clear(PktInQueue *pq)

+ 25 - 26
source/putty/sshverstring.c

@@ -17,7 +17,6 @@ struct ssh_verstring_state {
     int crState;
 
     Conf *conf;
-    Frontend *frontend;
     ptrlen prefix_wanted;
     char *our_protoversion;
     struct ssh_version_receiver *receiver;
@@ -88,7 +87,7 @@ BinaryPacketProtocol *ssh_verstring_new(
     assert(s->prefix_wanted.len <= PREFIX_MAXLEN);
 
     s->conf = conf_copy(conf);
-    s->frontend = frontend;
+    s->bpp.frontend = frontend;
     s->our_protoversion = dupstr(protoversion);
     s->receiver = rcv;
 
@@ -146,8 +145,8 @@ static int ssh_version_includes_v2(const char *ver)
     return ssh_versioncmp(ver, "1.99") >= 0;
 }
 
-#define vs_logevent(printf_args) \
-    logevent_and_free(s->frontend, dupprintf printf_args)
+#define bpp_logevent(printf_args) \
+    logevent_and_free(s->bpp.frontend, dupprintf printf_args)
 
 static void ssh_verstring_send(struct ssh_verstring_state *s)
 {
@@ -198,7 +197,7 @@ static void ssh_verstring_send(struct ssh_verstring_state *s)
         bufchain_add(s->bpp.out_raw, "\015", 1);
     bufchain_add(s->bpp.out_raw, "\012", 1);
 
-    vs_logevent(("We claim version: %s", s->our_vstring));
+    bpp_logevent(("We claim version: %s", s->our_vstring));
 }
 
 #define BPP_WAITFOR(minlen) do                          \
@@ -308,7 +307,7 @@ void ssh_verstring_handle_input(BinaryPacketProtocol *bpp)
         s->vslen--;
     s->vstring[s->vslen] = '\0';
 
-    vs_logevent(("Remote version: %s", s->vstring));
+    bpp_logevent(("Remote version: %s", s->vstring));
 
     /*
      * Pick out the protocol version and software version. The former
@@ -374,7 +373,7 @@ void ssh_verstring_handle_input(BinaryPacketProtocol *bpp)
         crStopV;
     }
 
-    vs_logevent(("Using SSH protocol version %d", s->major_protoversion));
+    bpp_logevent(("Using SSH protocol version %d", s->major_protoversion));
 
     if (!s->send_early) {
         /*
@@ -443,7 +442,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
          * sniffing.
          */
         s->remote_bugs |= BUG_CHOKES_ON_SSH1_IGNORE;
-        vs_logevent(("We believe remote version has SSH-1 ignore bug"));
+        bpp_logevent(("We believe remote version has SSH-1 ignore bug"));
     }
 
     if (conf_get_int(s->conf, CONF_sshbug_plainpw1) == FORCE_ON ||
@@ -455,8 +454,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
          * the password.
          */
         s->remote_bugs |= BUG_NEEDS_SSH1_PLAIN_PASSWORD;
-        vs_logevent(("We believe remote version needs a "
-                     "plain SSH-1 password"));
+        bpp_logevent(("We believe remote version needs a "
+                      "plain SSH-1 password"));
     }
 
     if (conf_get_int(s->conf, CONF_sshbug_rsa1) == FORCE_ON ||
@@ -468,8 +467,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
          * an AUTH_RSA message.
          */
         s->remote_bugs |= BUG_CHOKES_ON_RSA;
-        vs_logevent(("We believe remote version can't handle SSH-1 "
-                     "RSA authentication"));
+        bpp_logevent(("We believe remote version can't handle SSH-1 "
+                      "RSA authentication"));
     }
 
     if (conf_get_int(s->conf, CONF_sshbug_hmac2) == FORCE_ON ||
@@ -482,7 +481,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
          * These versions have the HMAC bug.
          */
         s->remote_bugs |= BUG_SSH2_HMAC;
-        vs_logevent(("We believe remote version has SSH-2 HMAC bug"));
+        bpp_logevent(("We believe remote version has SSH-2 HMAC bug"));
     }
 
     if (conf_get_int(s->conf, CONF_sshbug_derivekey2) == FORCE_ON ||
@@ -495,8 +494,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
          * generate the keys).
          */
         s->remote_bugs |= BUG_SSH2_DERIVEKEY;
-        vs_logevent(("We believe remote version has SSH-2 "
-                     "key-derivation bug"));
+        bpp_logevent(("We believe remote version has SSH-2 "
+                      "key-derivation bug"));
     }
 
     if (conf_get_int(s->conf, CONF_sshbug_rsapad2) == FORCE_ON ||
@@ -509,7 +508,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
          * These versions have the SSH-2 RSA padding bug.
          */
         s->remote_bugs |= BUG_SSH2_RSA_PADDING;
-        vs_logevent(("We believe remote version has SSH-2 RSA padding bug"));
+        bpp_logevent(("We believe remote version has SSH-2 RSA padding bug"));
     }
 
     if (conf_get_int(s->conf, CONF_sshbug_pksessid2) == FORCE_ON ||
@@ -520,8 +519,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
          * public-key authentication.
          */
         s->remote_bugs |= BUG_SSH2_PK_SESSIONID;
-        vs_logevent(("We believe remote version has SSH-2 "
-                     "public-key-session-ID bug"));
+        bpp_logevent(("We believe remote version has SSH-2 "
+                      "public-key-session-ID bug"));
     }
 
     if (conf_get_int(s->conf, CONF_sshbug_rekey2) == FORCE_ON ||
@@ -537,7 +536,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
          * These versions have the SSH-2 rekey bug.
          */
         s->remote_bugs |= BUG_SSH2_REKEY;
-        vs_logevent(("We believe remote version has SSH-2 rekey bug"));
+        bpp_logevent(("We believe remote version has SSH-2 rekey bug"));
     }
 
     if (conf_get_int(s->conf, CONF_sshbug_maxpkt2) == FORCE_ON ||
@@ -548,8 +547,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
          * This version ignores our makpkt and needs to be throttled.
          */
         s->remote_bugs |= BUG_SSH2_MAXPKT;
-        vs_logevent(("We believe remote version ignores SSH-2 "
-                     "maximum packet size"));
+        bpp_logevent(("We believe remote version ignores SSH-2 "
+                      "maximum packet size"));
     }
 
     if (conf_get_int(s->conf, CONF_sshbug_ignore2) == FORCE_ON) {
@@ -558,7 +557,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
          * none detected automatically.
          */
         s->remote_bugs |= BUG_CHOKES_ON_SSH2_IGNORE;
-        vs_logevent(("We believe remote version has SSH-2 ignore bug"));
+        bpp_logevent(("We believe remote version has SSH-2 ignore bug"));
     }
 
     if (conf_get_int(s->conf, CONF_sshbug_oldgex2) == FORCE_ON ||
@@ -570,7 +569,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
          * we use the newer version.
          */
         s->remote_bugs |= BUG_SSH2_OLDGEX;
-        vs_logevent(("We believe remote version has outdated SSH-2 GEX"));
+        bpp_logevent(("We believe remote version has outdated SSH-2 GEX"));
     }
 
     if (conf_get_int(s->conf, CONF_sshbug_winadj) == FORCE_ON) {
@@ -579,7 +578,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
          * reason or another. Currently, none detected automatically.
          */
         s->remote_bugs |= BUG_CHOKES_ON_WINADJ;
-        vs_logevent(("We believe remote version has winadj bug"));
+        bpp_logevent(("We believe remote version has winadj bug"));
     }
 
     if (conf_get_int(s->conf, CONF_sshbug_chanreq) == FORCE_ON ||
@@ -596,8 +595,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
          * https://secure.ucc.asn.au/hg/dropbear/rev/cd02449b709c
          */
         s->remote_bugs |= BUG_SENDS_LATE_REQUEST_REPLY;
-        vs_logevent(("We believe remote version has SSH-2 "
-                     "channel request bug"));
+        bpp_logevent(("We believe remote version has SSH-2 "
+                      "channel request bug"));
     }
 }
 

+ 12 - 3
source/putty/x11fwd.c

@@ -175,11 +175,14 @@ int x11_authcmp(void *av, void *bv)
     }
 }
 
-struct X11Display *x11_setup_display(const char *display, Conf *conf)
+struct X11Display *x11_setup_display(const char *display, Conf *conf,
+                                     char **error_msg)
 {
     struct X11Display *disp = snew(struct X11Display);
     char *localcopy;
 
+    *error_msg = NULL;
+
     if (!display || !*display) {
 	localcopy = platform_get_x_display();
 	if (!localcopy || !*localcopy) {
@@ -217,9 +220,12 @@ struct X11Display *x11_setup_display(const char *display, Conf *conf)
 
 	colon = host_strrchr(localcopy, ':');
 	if (!colon) {
+            *error_msg = dupprintf("display name '%s' has no ':number'"
+                                   " suffix", localcopy);
+
 	    sfree(disp);
 	    sfree(localcopy);
-	    return NULL;	       /* FIXME: report a specific error? */
+	    return NULL;
 	}
 
 	*colon++ = '\0';
@@ -275,11 +281,14 @@ struct X11Display *x11_setup_display(const char *display, Conf *conf)
                                  NULL, NULL);
     
 	if ((err = sk_addr_error(disp->addr)) != NULL) {
+            *error_msg = dupprintf("unable to resolve host name '%s' in "
+                                   "display name", disp->hostname);
+
 	    sk_addr_free(disp->addr);
 	    sfree(disp->hostname);
 	    sfree(disp->unixsocketpath);
 	    sfree(disp);
-	    return NULL;	       /* FIXME: report an error */
+	    return NULL;
 	}
     }