Introduce a new checkbox and command-line option to inhibit use of
[u/mdw/putty] / pscp.c
diff --git a/pscp.c b/pscp.c
index 19e5df4..b67782e 100644 (file)
--- a/pscp.c
+++ b/pscp.c
@@ -220,6 +220,15 @@ int from_backend(void *frontend, int is_stderr, const char *data, int datalen)
 
     return 0;
 }
+int from_backend_untrusted(void *frontend_handle, const char *data, int len)
+{
+    /*
+     * No "untrusted" output should get here (the way the code is
+     * currently, it's all diverted by FLAG_STDERR).
+     */
+    assert(!"Unexpected call to from_backend_untrusted()");
+    return 0; /* not reached */
+}
 static int ssh_scp_recv(unsigned char *buf, int len)
 {
     outptr = buf;
@@ -537,26 +546,23 @@ static void print_stats(char *name, unsigned long size, unsigned long done,
  */
 static char *colon(char *str)
 {
-    /* Check and process IPv6 literal addresses
-     * (eg: 'jeroen@[2001:db8::1]:myfile.txt') */
-    char *ipv6 = strchr(str, '[');
-    if (ipv6) {
-       str = strchr(str, ']');
-       if (str) {
-           /* Terminate on the closing bracket */
-           *str++ = '\0';
-           return (str);
-       }
-       return (NULL);
-    }
-
     /* We ignore a leading colon, since the hostname cannot be
        empty. We also ignore a colon as second character because
        of filenames like f:myfile.txt. */
-    if (str[0] == '\0' || str[0] == ':' || str[1] == ':')
+    if (str[0] == '\0' || str[0] == ':' ||
+        (str[0] != '[' && str[1] == ':'))
        return (NULL);
-    while (*str != '\0' && *str != ':' && *str != '/' && *str != '\\')
+    while (*str != '\0' && *str != ':' && *str != '/' && *str != '\\') {
+       if (*str == '[') {
+           /* Skip over IPv6 literal addresses
+            * (eg: 'jeroen@[2001:db8::1]:myfile.txt') */
+           char *ipv6_end = strchr(str, ']');
+           if (ipv6_end) {
+               str = ipv6_end;
+           }
+       }
        str++;
+    }
     if (*str == ':')
        return (str);
     else
@@ -2204,7 +2210,6 @@ int psftp_main(int argc, char *argv[])
 #endif
        ;
     cmdline_tooltype = TOOLTYPE_FILETRANSFER;
-    ssh_get_line = &console_get_line;
     sk_init();
 
     /* Load Default Settings before doing anything else. */