rcolebaugh / rpms / openssh

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