socks5_negotiate(): rather than using an uninitialised value when passed
authorben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sat, 12 Apr 2003 21:23:58 +0000 (21:23 +0000)
committerben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sat, 12 Apr 2003 21:23:58 +0000 (21:23 +0000)
an address of an invalid type, assert() that it will never happen.
Do something similar for SOCKS4 as well.

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

proxy.c

diff --git a/proxy.c b/proxy.c
index 0065b5c..cda7511 100644 (file)
--- a/proxy.c
+++ b/proxy.c
@@ -695,6 +695,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;
@@ -999,7 +1000,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);