projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
socks5_negotiate(): rather than using an uninitialised value when passed
[u/mdw/putty]
/
portfwd.c
diff --git
a/portfwd.c
b/portfwd.c
index
03cbd67
..
e21ed3a
100644
(file)
--- a/
portfwd.c
+++ b/
portfwd.c
@@
-74,7
+74,7
@@
struct PFwdPrivate {
* we can also use them as a buffer and pointer for reading
* data from the SOCKS client.
*/
* we can also use them as a buffer and pointer for reading
* data from the SOCKS client.
*/
- char hostname[256];
+ char hostname[256
+8
];
int port;
/*
* When doing dynamic port forwarding, we can receive
int port;
/*
* When doing dynamic port forwarding, we can receive
@@
-159,15
+159,15
@@
static int pfd_receive(Plug plug, int urgent, char *data, int len)
int len;
if (pr->dynamic == 0x4000) {
pr->dynamic = 0x4001;
int len;
if (pr->dynamic == 0x4000) {
pr->dynamic = 0x4001;
+ pr->port = 8; /* reset buffer to overwrite name */
continue;
}
pr->hostname[0] = 0; /* reply version code */
pr->hostname[1] = 90; /* request granted */
sk_write(pr->s, pr->hostname, 8);
continue;
}
pr->hostname[0] = 0; /* reply version code */
pr->hostname[1] = 90; /* request granted */
sk_write(pr->s, pr->hostname, 8);
+ len= pr->port;
pr->port = GET_16BIT_MSB_FIRST(pr->hostname+2);
pr->port = GET_16BIT_MSB_FIRST(pr->hostname+2);
- len = strlen(pr->hostname+8);
- memmove(pr->hostname, pr->hostname + 8 + len + 1,
- lenof(pr->hostname) - (8 + len + 1));
+ memmove(pr->hostname, pr->hostname + 8, len);
goto connect;
} else {
/*
goto connect;
} else {
/*
@@
-220,7
+220,7
@@
static int pfd_receive(Plug plug, int urgent, char *data, int len)
}
if (pr->dynamic == 0x5001) {
}
if (pr->dynamic == 0x5001) {
- int atype, alen;
+ int atype, alen
= 0
;
if (pr->port < 6) continue;
atype = (unsigned char)pr->hostname[3];
if (atype == 1) /* IPv4 address */
if (pr->port < 6) continue;
atype = (unsigned char)pr->hostname[3];
if (atype == 1) /* IPv4 address */
@@
-362,6
+362,7
@@
char *pfd_newconnect(Socket *s, char *hostname, int port, void *c,
pr->ready = 1;
pr->c = c;
pr->backhandle = NULL; /* we shouldn't need this */
pr->ready = 1;
pr->c = c;
pr->backhandle = NULL; /* we shouldn't need this */
+ pr->dynamic = 0;
pr->s = *s = new_connection(addr, dummy_realhost, port,
0, 1, 0, (Plug) pr, cfg);
pr->s = *s = new_connection(addr, dummy_realhost, port,
0, 1, 0, (Plug) pr, cfg);
@@
-415,6
+416,7
@@
static int pfd_accepting(Plug p, void *sock)
pr->port = 0; /* hostname buffer is so far empty */
sk_set_frozen(s, 0); /* we want to receive SOCKS _now_! */
} else {
pr->port = 0; /* hostname buffer is so far empty */
sk_set_frozen(s, 0); /* we want to receive SOCKS _now_! */
} else {
+ pr->dynamic = 0;
strcpy(pr->hostname, org->hostname);
pr->port = org->port;
pr->c = new_sock_channel(org->backhandle, s);
strcpy(pr->hostname, org->hostname);
pr->port = org->port;
pr->c = new_sock_channel(org->backhandle, s);