6cf9b8e
diff -up openssh-7.4p1/channels.c.coverity openssh-7.4p1/channels.c
6cf9b8e
--- openssh-7.4p1/channels.c.coverity	2016-12-23 16:40:26.881788686 +0100
6cf9b8e
+++ openssh-7.4p1/channels.c	2016-12-23 16:42:36.244818763 +0100
6cf9b8e
@@ -288,11 +288,11 @@ channel_register_fds(Channel *c, int rfd
Jan F. Chadima 3b545be
 
Jan F. Chadima 3b545be
 	/* enable nonblocking mode */
Jan F. Chadima 3b545be
 	if (nonblock) {
Jan F. Chadima 3b545be
-		if (rfd != -1)
Jan F. Chadima 3b545be
+		if (rfd >= 0)
Jan F. Chadima 3b545be
 			set_nonblock(rfd);
Jan F. Chadima 3b545be
-		if (wfd != -1)
Jan F. Chadima 3b545be
+		if (wfd >= 0)
Jan F. Chadima 3b545be
 			set_nonblock(wfd);
Jan F. Chadima 3b545be
-		if (efd != -1)
Jan F. Chadima 3b545be
+		if (efd >= 0)
Jan F. Chadima 3b545be
 			set_nonblock(efd);
Jan F. Chadima 3b545be
 	}
Jan F. Chadima 3b545be
 }
6cf9b8e
diff -up openssh-7.4p1/monitor.c.coverity openssh-7.4p1/monitor.c
6cf9b8e
--- openssh-7.4p1/monitor.c.coverity	2016-12-23 16:40:26.888788688 +0100
6cf9b8e
+++ openssh-7.4p1/monitor.c	2016-12-23 16:40:26.900788691 +0100
6cf9b8e
@@ -411,7 +411,7 @@ monitor_child_preauth(Authctxt *_authctx
def1deb
 	mm_get_keystate(ssh, pmonitor);
Jan F. Chadima cff1d0c
 
Jan F. Chadima cff1d0c
 	/* Drain any buffered messages from the child */
Jan F. Chadima cff1d0c
-	while (pmonitor->m_log_recvfd != -1 && monitor_read_log(pmonitor) == 0)
Jan F. Chadima cff1d0c
+	while (pmonitor->m_log_recvfd >= 0 && monitor_read_log(pmonitor) == 0)
Jan F. Chadima cff1d0c
 		;
Jan F. Chadima cff1d0c
 
3cd4899
 	if (pmonitor->m_recvfd >= 0)
6cf9b8e
diff -up openssh-7.4p1/monitor_wrap.c.coverity openssh-7.4p1/monitor_wrap.c
6cf9b8e
--- openssh-7.4p1/monitor_wrap.c.coverity	2016-12-23 16:40:26.892788689 +0100
6cf9b8e
+++ openssh-7.4p1/monitor_wrap.c	2016-12-23 16:40:26.900788691 +0100
6cf9b8e
@@ -525,10 +525,10 @@ mm_pty_allocate(int *ptyfd, int *ttyfd,
Jan F. Chadima cff1d0c
 	if ((tmp1 = dup(pmonitor->m_recvfd)) == -1 ||
Jan F. Chadima cff1d0c
 	    (tmp2 = dup(pmonitor->m_recvfd)) == -1) {
Jan F. Chadima cff1d0c
 		error("%s: cannot allocate fds for pty", __func__);
Jan F. Chadima cff1d0c
-		if (tmp1 > 0)
Jan F. Chadima cff1d0c
+		if (tmp1 >= 0)
Jan F. Chadima cff1d0c
 			close(tmp1);
Jan F. Chadima cff1d0c
-		if (tmp2 > 0)
Jan F. Chadima cff1d0c
-			close(tmp2);
Jan F. Chadima cff1d0c
+		/*DEAD CODE if (tmp2 >= 0)
Jan F. Chadima cff1d0c
+			close(tmp2);*/
Jan F. Chadima cff1d0c
 		return 0;
Jan F. Chadima cff1d0c
 	}
Jan F. Chadima cff1d0c
 	close(tmp1);
6cf9b8e
diff -up openssh-7.4p1/openbsd-compat/bindresvport.c.coverity openssh-7.4p1/openbsd-compat/bindresvport.c
6cf9b8e
--- openssh-7.4p1/openbsd-compat/bindresvport.c.coverity	2016-12-19 05:59:41.000000000 +0100
6cf9b8e
+++ openssh-7.4p1/openbsd-compat/bindresvport.c	2016-12-23 16:40:26.901788691 +0100
132f8f8
@@ -58,7 +58,7 @@ bindresvport_sa(int sd, struct sockaddr
Jan F. Chadima ea97ffa
 	struct sockaddr_in6 *in6;
Jan F. Chadima ea97ffa
 	u_int16_t *portp;
Jan F. Chadima ea97ffa
 	u_int16_t port;
Jan F. Chadima ea97ffa
-	socklen_t salen;
Jan F. Chadima ea97ffa
+	socklen_t salen = sizeof(struct sockaddr_storage);
Jan F. Chadima ea97ffa
 	int i;
Jan F. Chadima ea97ffa
 
Jan F. Chadima ea97ffa
 	if (sa == NULL) {
6cf9b8e
diff -up openssh-7.4p1/scp.c.coverity openssh-7.4p1/scp.c
6cf9b8e
--- openssh-7.4p1/scp.c.coverity	2016-12-23 16:40:26.856788681 +0100
6cf9b8e
+++ openssh-7.4p1/scp.c	2016-12-23 16:40:26.901788691 +0100
6cf9b8e
@@ -157,7 +157,7 @@ killchild(int signo)
Jan F. Chadima 3b545be
 {
Jan F. Chadima 3b545be
 	if (do_cmd_pid > 1) {
Jan F. Chadima 3b545be
 		kill(do_cmd_pid, signo ? signo : SIGTERM);
Jan F. Chadima 3b545be
-		waitpid(do_cmd_pid, NULL, 0);
Jan F. Chadima 3b545be
+		(void) waitpid(do_cmd_pid, NULL, 0);
Jan F. Chadima 3b545be
 	}
Jan F. Chadima 3b545be
 
Jan F. Chadima 3b545be
 	if (signo)
6cf9b8e
diff -up openssh-7.4p1/servconf.c.coverity openssh-7.4p1/servconf.c
6cf9b8e
--- openssh-7.4p1/servconf.c.coverity	2016-12-23 16:40:26.896788690 +0100
6cf9b8e
+++ openssh-7.4p1/servconf.c	2016-12-23 16:40:26.901788691 +0100
6cf9b8e
@@ -1547,7 +1547,7 @@ process_server_config_line(ServerOptions
Jan F. Chadima ea97ffa
 			fatal("%s line %d: Missing subsystem name.",
Jan F. Chadima ea97ffa
 			    filename, linenum);
Jan F. Chadima ea97ffa
 		if (!*activep) {
Jan F. Chadima ea97ffa
-			arg = strdelim(&cp;;
Jan F. Chadima ea97ffa
+			/*arg =*/ (void) strdelim(&cp;;
Jan F. Chadima ea97ffa
 			break;
Jan F. Chadima ea97ffa
 		}
Jan F. Chadima ea97ffa
 		for (i = 0; i < options->num_subsystems; i++)
6cf9b8e
@@ -1638,8 +1638,9 @@ process_server_config_line(ServerOptions
Jan F. Chadima cff1d0c
 		if (*activep && *charptr == NULL) {
Jan F. Chadima cff1d0c
 			*charptr = tilde_expand_filename(arg, getuid());
Jan F. Chadima cff1d0c
 			/* increase optional counter */
Jan F. Chadima cff1d0c
-			if (intptr != NULL)
Jan F. Chadima cff1d0c
-				*intptr = *intptr + 1;
Jan F. Chadima cff1d0c
+			/* DEAD CODE intptr is still NULL ;)
Jan F. Chadima cff1d0c
+  			 if (intptr != NULL)
Jan F. Chadima cff1d0c
+				*intptr = *intptr + 1; */
Jan F. Chadima cff1d0c
 		}
Jan F. Chadima cff1d0c
 		break;
Jan F. Chadima cff1d0c
 
6cf9b8e
diff -up openssh-7.4p1/serverloop.c.coverity openssh-7.4p1/serverloop.c
6cf9b8e
--- openssh-7.4p1/serverloop.c.coverity	2016-12-19 05:59:41.000000000 +0100
6cf9b8e
+++ openssh-7.4p1/serverloop.c	2016-12-23 16:40:26.902788691 +0100
6cf9b8e
@@ -125,13 +125,13 @@ notify_setup(void)
Jan F. Chadima 3b545be
 static void
Jan F. Chadima 3b545be
 notify_parent(void)
Jan F. Chadima 3b545be
 {
Jan F. Chadima 3b545be
-	if (notify_pipe[1] != -1)
Jan F. Chadima 3b545be
+	if (notify_pipe[1] >= 0)
84822b5
 		(void)write(notify_pipe[1], "", 1);
Jan F. Chadima 3b545be
 }
Jan F. Chadima 3b545be
 static void
Jan F. Chadima 3b545be
 notify_prepare(fd_set *readset)
Jan F. Chadima 3b545be
 {
Jan F. Chadima 3b545be
-	if (notify_pipe[0] != -1)
Jan F. Chadima 3b545be
+	if (notify_pipe[0] >= 0)
Jan F. Chadima 3b545be
 		FD_SET(notify_pipe[0], readset);
Jan F. Chadima 3b545be
 }
Jan F. Chadima 3b545be
 static void
6cf9b8e
@@ -139,8 +139,8 @@ notify_done(fd_set *readset)
Jan F. Chadima 3b545be
 {
Jan F. Chadima 3b545be
 	char c;
Jan F. Chadima 3b545be
 
Jan F. Chadima 3b545be
-	if (notify_pipe[0] != -1 && FD_ISSET(notify_pipe[0], readset))
Jan F. Chadima 3b545be
-		while (read(notify_pipe[0], &c, 1) != -1)
Jan F. Chadima 3b545be
+	if (notify_pipe[0] >= 0 && FD_ISSET(notify_pipe[0], readset))
Jan F. Chadima 3b545be
+		while (read(notify_pipe[0], &c, 1) >= 0)
bbf61da
 			debug2("%s: reading", __func__);
Jan F. Chadima 3b545be
 }
Jan F. Chadima 3b545be
 
6cf9b8e
@@ -518,7 +518,7 @@ server_request_tun(void)
def1deb
 		debug("%s: invalid tun", __func__);
def1deb
 		goto done;
Jan F. Chadima 3b545be
 	}
3cd4899
-	if (auth_opts->force_tun_device != -1) {
3cd4899
+	if (auth_opts->force_tun_device >= 0) {
def1deb
 		if (tun != SSH_TUNID_ANY &&
def1deb
 		    auth_opts->force_tun_device != (int)tun)
Jan F. Chadima 3b545be
 			goto done;
6cf9b8e
diff -up openssh-7.4p1/sftp.c.coverity openssh-7.4p1/sftp.c
6cf9b8e
--- openssh-7.4p1/sftp.c.coverity	2016-12-19 05:59:41.000000000 +0100
6cf9b8e
+++ openssh-7.4p1/sftp.c	2016-12-23 16:40:26.903788691 +0100
6cf9b8e
@@ -224,7 +224,7 @@ killchild(int signo)
51f5c1c
 	pid = sshpid;
51f5c1c
 	if (pid > 1) {
51f5c1c
 		kill(pid, SIGTERM);
51f5c1c
-		waitpid(pid, NULL, 0);
51f5c1c
+		(void) waitpid(pid, NULL, 0);
84822b5
 	}
84822b5
 
84822b5
 	_exit(1);
6cf9b8e
diff -up openssh-7.4p1/ssh-agent.c.coverity openssh-7.4p1/ssh-agent.c
6cf9b8e
--- openssh-7.4p1/ssh-agent.c.coverity	2016-12-19 05:59:41.000000000 +0100
6cf9b8e
+++ openssh-7.4p1/ssh-agent.c	2016-12-23 16:40:26.903788691 +0100
6cf9b8e
@@ -1220,8 +1220,8 @@ main(int ac, char **av)
Jan F. Chadima ea97ffa
 	sanitise_stdfd();
Jan F. Chadima ea97ffa
 
Jan F. Chadima ea97ffa
 	/* drop */
Jan F. Chadima ea97ffa
-	setegid(getgid());
Jan F. Chadima ea97ffa
-	setgid(getgid());
Jan F. Chadima ea97ffa
+	(void) setegid(getgid());
Jan F. Chadima ea97ffa
+	(void) setgid(getgid());
Jan F. Chadima ea97ffa
 
5878ebb
 	platform_disable_tracing(0);	/* strict=no */
5878ebb
 
6cf9b8e
diff -up openssh-7.4p1/sshd.c.coverity openssh-7.4p1/sshd.c
6cf9b8e
--- openssh-7.4p1/sshd.c.coverity	2016-12-23 16:40:26.897788690 +0100
6cf9b8e
+++ openssh-7.4p1/sshd.c	2016-12-23 16:40:26.904788692 +0100
6cf9b8e
@@ -691,8 +691,10 @@ privsep_preauth(Authctxt *authctxt)
13073f8
 
def1deb
 		privsep_preauth_child(ssh);
Jan F. Chadima cff1d0c
 		setproctitle("%s", "[net]");
Jan F. Chadima cff1d0c
-		if (box != NULL)
Jan F. Chadima cff1d0c
+		if (box != NULL) {
Jan F. Chadima cff1d0c
 			ssh_sandbox_child(box);
84822b5
+			free(box);
Jan F. Chadima cff1d0c
+		}
Jan F. Chadima cff1d0c
 
Jan F. Chadima cff1d0c
 		return 0;
Jan F. Chadima cff1d0c
 	}
6cf9b8e
@@ -1386,6 +1388,9 @@ server_accept_loop(int *sock_in, int *so
def1deb
 			explicit_bzero(rnd, sizeof(rnd));
def1deb
 		}
Jan F. Chadima 3b545be
 	}
Jan F. Chadima 3b545be
+
Jan F. Chadima 3b545be
+	if (fdset != NULL)
84822b5
+		free(fdset);
Jan F. Chadima 3b545be
 }
Jan F. Chadima 3b545be
 
5878ebb
 /*