瀏覽代碼

Merge branch 'thirdparty_dev' into dev

# Conflicts:
#	source/putty/sshverstring.c

Source commit: 0bdc6fed8638bedf430c957ca3f30c2ade966ea0
Martin Prikryl 6 年之前
父節點
當前提交
62a4b44e92

+ 1 - 1
source/putty/putty.h

@@ -1300,7 +1300,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);

+ 22 - 13
source/putty/ssh.h

@@ -94,12 +94,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);
@@ -112,21 +112,24 @@ void pq_out_init(PktOutQueue *pq, Frontend * frontend); // WINSCP
 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.
@@ -780,10 +783,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 */
@@ -943,8 +948,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);

+ 7 - 0
source/putty/ssh1bpp.c

@@ -68,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)
@@ -84,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));
     }
 }
 
@@ -224,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"));

+ 30 - 0
source/putty/ssh2bpp.c

@@ -83,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,
@@ -108,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;
@@ -116,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;
     }
@@ -124,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(
@@ -147,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;
     }
@@ -154,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;
     }
@@ -162,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

@@ -1251,12 +1251,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

@@ -2160,20 +2160,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
@@ -2229,19 +2215,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.
      */

+ 8 - 6
source/putty/sshcommon.c

@@ -76,9 +76,10 @@ static IdempotentCallback ic_pktin_free = {
 };
 #endif
 
-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;
 
@@ -116,9 +117,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;
 
@@ -136,7 +138,7 @@ void pq_in_init(PktInQueue *pq, Frontend * frontend) // WINSCP
     pq->pqb.ic = NULL;
     pq->pqb.frontend = frontend;
     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, Frontend * frontend) // WINSCP
@@ -144,7 +146,7 @@ void pq_out_init(PktOutQueue *pq, Frontend * frontend) // WINSCP
     pq->pqb.ic = NULL;
     pq->pqb.frontend = frontend;
     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->bpp.frontend = frontend;
     s->our_protoversion = dupstr(protoversion);
     s->receiver = rcv;
@@ -147,8 +146,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)
 {
@@ -199,7 +198,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                          \
@@ -309,7 +308,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
@@ -375,7 +374,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) {
         /*
@@ -444,7 +443,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 ||
@@ -456,8 +455,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 ||
@@ -469,8 +468,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 ||
@@ -483,7 +482,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 ||
@@ -496,8 +495,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 ||
@@ -510,7 +509,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 ||
@@ -521,8 +520,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 ||
@@ -538,7 +537,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 ||
@@ -549,8 +548,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) {
@@ -559,7 +558,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 ||
@@ -571,7 +570,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) {
@@ -580,7 +579,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 ||
@@ -597,8 +596,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"));
     }
 }
 

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

@@ -1160,7 +1160,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;
@@ -1183,7 +1183,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
@@ -1192,9 +1191,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);
+    }
 }
 
 #endif

+ 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;
 	}
     }