vishalmishra434 / rpms / openssh

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