Support for non-ISO-8859-1 X keysyms. So in particular, pterm in a
[u/mdw/putty] / proxy.c
diff --git a/proxy.c b/proxy.c
index 0a61741..2ea0bc8 100644 (file)
--- a/proxy.c
+++ b/proxy.c
@@ -269,7 +269,8 @@ static int proxy_for_destination (SockAddr addr, char *hostname, int port,
     if (addr) {
        sk_getaddr(addr, hostip, 64);
        hostip_len = strlen(hostip);
-    }
+    } else
+       hostip_len = 0;                /* placate gcc; shouldn't be required */
 
     hostname_len = strlen(hostname);
 
@@ -281,7 +282,7 @@ static int proxy_for_destination (SockAddr addr, char *hostname, int port,
 
     while (exclude_list[s]) {
        while (exclude_list[s] &&
-              (isspace(exclude_list[s]) ||
+              (isspace((unsigned char)exclude_list[s]) ||
                exclude_list[s] == ',')) s++;
 
        if (!exclude_list[s]) break;
@@ -289,7 +290,7 @@ static int proxy_for_destination (SockAddr addr, char *hostname, int port,
        e = s;
 
        while (exclude_list[e] &&
-              (isalnum(exclude_list[e]) ||
+              (isalnum((unsigned char)exclude_list[e]) ||
                exclude_list[e] == '-' ||
                exclude_list[e] == '.' ||
                exclude_list[e] == '*')) e++;
@@ -325,7 +326,7 @@ static int proxy_for_destination (SockAddr addr, char *hostname, int port,
 
        /* Make sure we really have reached the next comma or end-of-string */
        while (exclude_list[s] &&
-              !isspace(exclude_list[s]) &&
+              !isspace((unsigned char)exclude_list[s]) &&
               exclude_list[s] != ',') s++;
     }
 
@@ -378,7 +379,7 @@ Socket new_connection(SockAddr addr, char *hostname,
        SockAddr proxy_addr;
        char *proxy_canonical_name, *err;
 
-       ret = smalloc(sizeof(struct Socket_proxy_tag));
+       ret = snew(struct Socket_proxy_tag);
        ret->fn = &socket_fn_table;
        ret->cfg = *cfg;               /* STRUCTURE COPY */
        ret->plug = plug;
@@ -413,7 +414,7 @@ Socket new_connection(SockAddr addr, char *hostname,
 
        /* create the proxy plug to map calls from the actual
         * socket into our proxy socket layer */
-       pplug = smalloc(sizeof(struct Plug_proxy_tag));
+       pplug = snew(struct Plug_proxy_tag);
        pplug->fn = &plug_fn_table;
        pplug->proxy_socket = ret;
 
@@ -519,7 +520,7 @@ int proxy_http_negotiate (Proxy_Socket p, int change)
            int i, j, len;
            sprintf(buf, "%s:%s", p->cfg.proxy_username, p->cfg.proxy_password);
            len = strlen(buf);
-           sprintf(buf2, "Proxy-Authorization: basic ");
+           sprintf(buf2, "Proxy-Authorization: Basic ");
            for (i = 0, j = strlen(buf2); i < len; i += 3, j += 4)
                base64_encode_atom((unsigned char *)(buf+i),
                                   (len-i > 3 ? 3 : len-i), buf2+j);
@@ -579,7 +580,7 @@ int proxy_http_negotiate (Proxy_Socket p, int change)
            /* get the status line */
            len = bufchain_size(&p->pending_input_data);
            assert(len > 0);           /* or we wouldn't be here */
-           data = smalloc(len);
+           data = snewn(len, char);
            bufchain_fetch(&p->pending_input_data, data, len);
 
            eol = get_line_end(data, len);
@@ -627,7 +628,7 @@ int proxy_http_negotiate (Proxy_Socket p, int change)
 
            len = bufchain_size(&p->pending_input_data);
            assert(len > 0);           /* or we wouldn't be here */
-           data = smalloc(len);
+           data = snewn(len, char);
            datap = data;
            bufchain_fetch(&p->pending_input_data, data, len);
 
@@ -695,6 +696,7 @@ int proxy_socks4_negotiate (Proxy_Socket p, int change)
            namelen = 0;
            sk_addrcopy(p->remote_addr, addr);
        } else {                       /* type == ADDRTYPE_NAME */
+           assert(type == ADDRTYPE_NAME);
            sk_getaddr(p->remote_addr, hostname, lenof(hostname));
            namelen = strlen(hostname) + 1;   /* include the NUL */
            addr[0] = addr[1] = addr[2] = 0;
@@ -702,7 +704,7 @@ int proxy_socks4_negotiate (Proxy_Socket p, int change)
        }
 
        length = strlen(p->cfg.proxy_username) + namelen + 9;
-       command = (char*) smalloc(length);
+       command = snewn(length, char);
        strcpy(command + 8, p->cfg.proxy_username);
 
        command[0] = 4; /* version 4 */
@@ -999,7 +1001,8 @@ int proxy_socks5_negotiate (Proxy_Socket p, int change)
                len = 22;              /* 4 hdr + 16 addr + 2 trailer */
                command[3] = 4; /* IPv6 */
                sk_addrcopy(p->remote_addr, command+4);
-           } else if (type == ADDRTYPE_NAME) {
+           } else {
+               assert(type == ADDRTYPE_NAME);
                command[3] = 3;
                sk_getaddr(p->remote_addr, command+5, 256);
                command[4] = strlen(command+5);