rutwa189 / rpms / openssh

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