Mercurial > dropbear
comparison cli-tcpfwd.c @ 1355:3fdd8c5a0195 fuzz
merge main to fuzz
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 18 May 2017 23:45:10 +0800 |
parents | e47e4b8a005d |
children | f7a53832501d |
comparison
equal
deleted
inserted
replaced
1354:7618759e9327 | 1355:3fdd8c5a0195 |
---|---|
30 #include "runopts.h" | 30 #include "runopts.h" |
31 #include "session.h" | 31 #include "session.h" |
32 #include "ssh.h" | 32 #include "ssh.h" |
33 #include "netio.h" | 33 #include "netio.h" |
34 | 34 |
35 #ifdef ENABLE_CLI_REMOTETCPFWD | 35 #if DROPBEAR_CLI_REMOTETCPFWD |
36 static int newtcpforwarded(struct Channel * channel); | 36 static int newtcpforwarded(struct Channel * channel); |
37 | 37 |
38 const struct ChanType cli_chan_tcpremote = { | 38 const struct ChanType cli_chan_tcpremote = { |
39 1, /* sepfds */ | 39 1, /* sepfds */ |
40 "forwarded-tcpip", | 40 "forwarded-tcpip", |
43 NULL, | 43 NULL, |
44 NULL | 44 NULL |
45 }; | 45 }; |
46 #endif | 46 #endif |
47 | 47 |
48 #ifdef ENABLE_CLI_LOCALTCPFWD | 48 #if DROPBEAR_CLI_LOCALTCPFWD |
49 static int cli_localtcp(const char* listenaddr, | 49 static int cli_localtcp(const char* listenaddr, |
50 unsigned int listenport, | 50 unsigned int listenport, |
51 const char* remoteaddr, | 51 const char* remoteaddr, |
52 unsigned int remoteport); | 52 unsigned int remoteport); |
53 static const struct ChanType cli_chan_tcplocal = { | 53 static const struct ChanType cli_chan_tcplocal = { |
58 NULL, | 58 NULL, |
59 NULL | 59 NULL |
60 }; | 60 }; |
61 #endif | 61 #endif |
62 | 62 |
63 #ifdef ENABLE_CLI_ANYTCPFWD | 63 #if DROPBEAR_CLI_ANYTCPFWD |
64 static void fwd_failed(const char* format, ...) ATTRIB_PRINTF(1,2); | 64 static void fwd_failed(const char* format, ...) ATTRIB_PRINTF(1,2); |
65 static void fwd_failed(const char* format, ...) | 65 static void fwd_failed(const char* format, ...) |
66 { | 66 { |
67 va_list param; | 67 va_list param; |
68 va_start(param, format); | 68 va_start(param, format); |
75 | 75 |
76 va_end(param); | 76 va_end(param); |
77 } | 77 } |
78 #endif | 78 #endif |
79 | 79 |
80 #ifdef ENABLE_CLI_LOCALTCPFWD | 80 #if DROPBEAR_CLI_LOCALTCPFWD |
81 void setup_localtcp() { | 81 void setup_localtcp() { |
82 m_list_elem *iter; | 82 m_list_elem *iter; |
83 int ret; | 83 int ret; |
84 | 84 |
85 TRACE(("enter setup_localtcp")) | 85 TRACE(("enter setup_localtcp")) |
142 m_free(tcpinfo); | 142 m_free(tcpinfo); |
143 } | 143 } |
144 TRACE(("leave cli_localtcp: %d", ret)) | 144 TRACE(("leave cli_localtcp: %d", ret)) |
145 return ret; | 145 return ret; |
146 } | 146 } |
147 #endif /* ENABLE_CLI_LOCALTCPFWD */ | 147 #endif /* DROPBEAR_CLI_LOCALTCPFWD */ |
148 | 148 |
149 #ifdef ENABLE_CLI_REMOTETCPFWD | 149 #if DROPBEAR_CLI_REMOTETCPFWD |
150 static void send_msg_global_request_remotetcp(const char *addr, int port) { | 150 static void send_msg_global_request_remotetcp(const char *addr, int port) { |
151 | 151 |
152 TRACE(("enter send_msg_global_request_remotetcp")) | 152 TRACE(("enter send_msg_global_request_remotetcp")) |
153 | 153 |
154 CHECKCLEARTOWRITE(); | 154 CHECKCLEARTOWRITE(); |
232 static int newtcpforwarded(struct Channel * channel) { | 232 static int newtcpforwarded(struct Channel * channel) { |
233 | 233 |
234 char *origaddr = NULL; | 234 char *origaddr = NULL; |
235 unsigned int origport; | 235 unsigned int origport; |
236 m_list_elem * iter = NULL; | 236 m_list_elem * iter = NULL; |
237 struct TCPFwdEntry *fwd; | 237 struct TCPFwdEntry *fwd = NULL; |
238 char portstring[NI_MAXSERV]; | 238 char portstring[NI_MAXSERV]; |
239 int err = SSH_OPEN_ADMINISTRATIVELY_PROHIBITED; | 239 int err = SSH_OPEN_ADMINISTRATIVELY_PROHIBITED; |
240 | 240 |
241 origaddr = buf_getstring(ses.payload, NULL); | 241 origaddr = buf_getstring(ses.payload, NULL); |
242 origport = buf_getint(ses.payload); | 242 origport = buf_getint(ses.payload); |
263 } | 263 } |
264 } | 264 } |
265 } | 265 } |
266 | 266 |
267 | 267 |
268 if (iter == NULL) { | 268 if (iter == NULL || fwd == NULL) { |
269 /* We didn't request forwarding on that port */ | 269 /* We didn't request forwarding on that port */ |
270 cleantext(origaddr); | 270 cleantext(origaddr); |
271 dropbear_log(LOG_INFO, "Server sent unrequested forward from \"%s:%d\"", | 271 dropbear_log(LOG_INFO, "Server sent unrequested forward from \"%s:%d\"", |
272 origaddr, origport); | 272 origaddr, origport); |
273 goto out; | 273 goto out; |
283 out: | 283 out: |
284 m_free(origaddr); | 284 m_free(origaddr); |
285 TRACE(("leave newtcpdirect: err %d", err)) | 285 TRACE(("leave newtcpdirect: err %d", err)) |
286 return err; | 286 return err; |
287 } | 287 } |
288 #endif /* ENABLE_CLI_REMOTETCPFWD */ | 288 #endif /* DROPBEAR_CLI_REMOTETCPFWD */ |