From 0d9c3fe70b828ff4af3a7b9fa20a169afa1a1fae Mon Sep 17 00:00:00 2001 From: Francois Perrad Date: Tue, 15 Nov 2016 15:36:05 +0100 Subject: [PATCH] initialize variable and protect against NULL dereferencement --- cli-tcpfwd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli-tcpfwd.c b/cli-tcpfwd.c index 95b2d7c..78f61f7 100644 --- a/cli-tcpfwd.c +++ b/cli-tcpfwd.c @@ -234,7 +234,7 @@ static int newtcpforwarded(struct Channel * channel) { 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 @@ static int newtcpforwarded(struct Channel * channel) { } - 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\"",