kentpeacock / rpms / openssh

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