diff 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
line wrap: on
line diff
--- a/cli-tcpfwd.c	Fri Jan 01 11:46:58 2016 +0100
+++ b/cli-tcpfwd.c	Tue Nov 15 15:36:05 2016 +0100
@@ -234,7 +234,7 @@
 	char *origaddr = NULL;
 	unsigned int origport;
 	m_list_elem * iter = NULL;
-	struct TCPFwdEntry *fwd;
+	struct TCPFwdEntry *fwd = NULL;
 	char portstring[NI_MAXSERV];
 	int err = SSH_OPEN_ADMINISTRATIVELY_PROHIBITED;
 
@@ -265,7 +265,7 @@
 	}
 
 
-	if (iter == NULL) {
+	if (iter == NULL || fwd == NULL) {
 		/* We didn't request forwarding on that port */
 		cleantext(origaddr);
 		dropbear_log(LOG_INFO, "Server sent unrequested forward from \"%s:%d\"",