comparison cli-tcpfwd.c @ 1327:e47e4b8a005d

initialize variable and protect against NULL dereferencement
author Francois Perrad <francois.perrad@gadz.org>
date Tue, 15 Nov 2016 15:36:05 +0100
parents 750ec4ec4cbe
children f7a53832501d
comparison
equal deleted inserted replaced
1326:79225928bf59 1327:e47e4b8a005d
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;