comparison svr-tcpfwd.c @ 943:185b241a0b4a coverity

merge
author Matt Johnston <matt@ucc.asn.au>
date Fri, 25 Jul 2014 22:23:50 +0800
parents 5daedffd0769
children 4121ca987e6a
comparison
equal deleted inserted replaced
924:204dc7bd62aa 943:185b241a0b4a
32 #include "packet.h" 32 #include "packet.h"
33 #include "listener.h" 33 #include "listener.h"
34 #include "runopts.h" 34 #include "runopts.h"
35 #include "auth.h" 35 #include "auth.h"
36 36
37 static void send_msg_request_failure();
38
39 static void send_msg_request_failure() {
40 CHECKCLEARTOWRITE();
41 buf_putbyte(ses.writepayload, SSH_MSG_REQUEST_FAILURE);
42 encrypt_packet();
43 }
44
45 #ifndef ENABLE_SVR_REMOTETCPFWD 37 #ifndef ENABLE_SVR_REMOTETCPFWD
46 38
47 /* This is better than SSH_MSG_UNIMPLEMENTED */ 39 /* This is better than SSH_MSG_UNIMPLEMENTED */
48 void recv_msg_global_request_remotetcp() { 40 void recv_msg_global_request_remotetcp() {
49 TRACE(("recv_msg_global_request_remotetcp: remote tcp forwarding not compiled in")) 41 TRACE(("recv_msg_global_request_remotetcp: remote tcp forwarding not compiled in"))
51 } 43 }
52 44
53 /* */ 45 /* */
54 #endif /* !ENABLE_SVR_REMOTETCPFWD */ 46 #endif /* !ENABLE_SVR_REMOTETCPFWD */
55 47
56 static void send_msg_request_success();
57 static int svr_cancelremotetcp(); 48 static int svr_cancelremotetcp();
58 static int svr_remotetcpreq(); 49 static int svr_remotetcpreq();
59 static int newtcpdirect(struct Channel * channel); 50 static int newtcpdirect(struct Channel * channel);
60 51
61 #ifdef ENABLE_SVR_REMOTETCPFWD 52 #ifdef ENABLE_SVR_REMOTETCPFWD
62 static const struct ChanType svr_chan_tcpremote = { 53 static const struct ChanType svr_chan_tcpremote = {
63 1, /* sepfds */ 54 1, /* sepfds */
64 "forwarded-tcpip", 55 "forwarded-tcpip",
65 NULL, 56 tcp_prio_inithandler,
66 NULL, 57 NULL,
67 NULL, 58 NULL,
68 NULL 59 NULL
69 }; 60 };
70 61
111 } 102 }
112 103
113 m_free(reqname); 104 m_free(reqname);
114 105
115 TRACE(("leave recv_msg_global_request")) 106 TRACE(("leave recv_msg_global_request"))
116 }
117
118
119 static void send_msg_request_success() {
120
121 CHECKCLEARTOWRITE();
122 buf_putbyte(ses.writepayload, SSH_MSG_REQUEST_SUCCESS);
123 encrypt_packet();
124
125 } 107 }
126 108
127 static int matchtcp(void* typedata1, void* typedata2) { 109 static int matchtcp(void* typedata1, void* typedata2) {
128 110
129 const struct TCPListener *info1 = (struct TCPListener*)typedata1; 111 const struct TCPListener *info1 = (struct TCPListener*)typedata1;
256 char portstring[NI_MAXSERV]; 238 char portstring[NI_MAXSERV];
257 int sock; 239 int sock;
258 int len; 240 int len;
259 int err = SSH_OPEN_ADMINISTRATIVELY_PROHIBITED; 241 int err = SSH_OPEN_ADMINISTRATIVELY_PROHIBITED;
260 242
243 TRACE(("newtcpdirect channel %d", channel->index))
244
261 if (svr_opts.nolocaltcp || !svr_pubkey_allows_tcpfwd()) { 245 if (svr_opts.nolocaltcp || !svr_pubkey_allows_tcpfwd()) {
262 TRACE(("leave newtcpdirect: local tcp forwarding disabled")) 246 TRACE(("leave newtcpdirect: local tcp forwarding disabled"))
263 goto out; 247 goto out;
264 } 248 }
265 249
297 281
298 /* We don't set readfd, that will get set after the connection's 282 /* We don't set readfd, that will get set after the connection's
299 * progress succeeds */ 283 * progress succeeds */
300 channel->writefd = sock; 284 channel->writefd = sock;
301 channel->initconn = 1; 285 channel->initconn = 1;
286
287 channel->prio = DROPBEAR_CHANNEL_PRIO_UNKNOWABLE;
302 288
303 err = SSH_OPEN_IN_PROGRESS; 289 err = SSH_OPEN_IN_PROGRESS;
304 290
305 out: 291 out:
306 m_free(desthost); 292 m_free(desthost);