vishalmishra434 / rpms / openssh

Forked from rpms/openssh a month ago
Clone
Jakub Jelen 132f8f
diff -up openssh-6.8p1/auth-pam.c.coverity openssh-6.8p1/auth-pam.c
Jakub Jelen 132f8f
--- openssh-6.8p1/auth-pam.c.coverity	2015-03-18 17:21:51.792265051 +0100
Jakub Jelen 132f8f
+++ openssh-6.8p1/auth-pam.c	2015-03-18 17:21:51.895264835 +0100
Jakub Jelen 132f8f
@@ -216,7 +216,12 @@ pthread_join(sp_pthread_t thread, void *
Jan F. Chadima 3b545b
 	if (sshpam_thread_status != -1)
Jan F. Chadima 3b545b
 		return (sshpam_thread_status);
Jan F. Chadima 3b545b
 	signal(SIGCHLD, sshpam_oldsig);
Jan F. Chadima 3b545b
-	waitpid(thread, &status, 0);
Jakub Jelen 580f98
+	while (waitpid(thread, &status, 0) < 0) {
Jakub Jelen 580f98
+		if (errno == EINTR)
Jan F. Chadima c870e6
+			continue;
Jakub Jelen 580f98
+		fatal("%s: waitpid: %s", __func__,
Jakub Jelen 580f98
+				strerror(errno));
Jan F. Chadima c870e6
+	}
Jan F. Chadima 3b545b
 	return (status);
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 #endif
Jakub Jelen 132f8f
diff -up openssh-6.8p1/channels.c.coverity openssh-6.8p1/channels.c
Jakub Jelen 132f8f
--- openssh-6.8p1/channels.c.coverity	2015-03-18 17:21:51.815265002 +0100
Jakub Jelen 132f8f
+++ openssh-6.8p1/channels.c	2015-03-18 17:21:51.896264833 +0100
Jakub Jelen 132f8f
@@ -243,11 +243,11 @@ channel_register_fds(Channel *c, int rfd
Jan F. Chadima 3b545b
 	channel_max_fd = MAX(channel_max_fd, wfd);
Jan F. Chadima 3b545b
 	channel_max_fd = MAX(channel_max_fd, efd);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
-	if (rfd != -1)
Jan F. Chadima 3b545b
+	if (rfd >= 0)
Jan F. Chadima 3b545b
 		fcntl(rfd, F_SETFD, FD_CLOEXEC);
Jan F. Chadima 3b545b
-	if (wfd != -1 && wfd != rfd)
Jan F. Chadima 3b545b
+	if (wfd >= 0 && wfd != rfd)
Jan F. Chadima 3b545b
 		fcntl(wfd, F_SETFD, FD_CLOEXEC);
Jan F. Chadima 3b545b
-	if (efd != -1 && efd != rfd && efd != wfd)
Jan F. Chadima 3b545b
+	if (efd >= 0 && efd != rfd && efd != wfd)
Jan F. Chadima 3b545b
 		fcntl(efd, F_SETFD, FD_CLOEXEC);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 	c->rfd = rfd;
Jakub Jelen 132f8f
@@ -265,11 +265,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 132f8f
@@ -3972,13 +3972,13 @@ connect_local_xsocket_path(const char *p
Jakub Jelen 580f98
 	int sock;
Jakub Jelen 580f98
 	struct sockaddr_un addr;
Jakub Jelen 580f98
 
Jakub Jelen 580f98
+	if (len <= 0)
Jakub Jelen 580f98
+		return -1;
Jakub Jelen 580f98
 	sock = socket(AF_UNIX, SOCK_STREAM, 0);
Jakub Jelen 580f98
 	if (sock < 0)
Jakub Jelen 580f98
 		error("socket: %.100s", strerror(errno));
Jakub Jelen 580f98
 	memset(&addr, 0, sizeof(addr));
Jakub Jelen 580f98
 	addr.sun_family = AF_UNIX;
Jakub Jelen 580f98
-	if (len <= 0)
Jakub Jelen 580f98
-		return -1;
Jakub Jelen 580f98
 	if (len > sizeof addr.sun_path)
Jakub Jelen 580f98
 		len = sizeof addr.sun_path;
Jakub Jelen 580f98
 	memcpy(addr.sun_path, pathname, len);
Jakub Jelen 132f8f
diff -up openssh-6.8p1/entropy.c.coverity openssh-6.8p1/entropy.c
Jakub Jelen 132f8f
--- openssh-6.8p1/entropy.c.coverity	2015-03-18 17:21:51.891264843 +0100
Jakub Jelen 132f8f
+++ openssh-6.8p1/entropy.c	2015-03-18 17:21:51.897264831 +0100
Jakub Jelen 132f8f
@@ -46,6 +46,7 @@
Jakub Jelen 580f98
 #include <openssl/err.h>
Jakub Jelen 580f98
 
Jakub Jelen 580f98
 #include "openbsd-compat/openssl-compat.h"
Jakub Jelen 580f98
+#include "openbsd-compat/port-linux.h"
Jakub Jelen 580f98
 
Jakub Jelen 580f98
 #include "ssh.h"
Jakub Jelen 580f98
 #include "misc.h"
Jakub Jelen 132f8f
diff -up openssh-6.8p1/monitor.c.coverity openssh-6.8p1/monitor.c
Jakub Jelen 132f8f
--- openssh-6.8p1/monitor.c.coverity	2015-03-18 17:21:51.887264852 +0100
Jakub Jelen 132f8f
+++ openssh-6.8p1/monitor.c	2015-03-18 17:21:51.897264831 +0100
Jakub Jelen 132f8f
@@ -444,7 +444,7 @@ monitor_child_preauth(Authctxt *_authctx
Petr Lautrbach 8a29de
 	mm_get_keystate(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
 
Petr Lautrbach 8a29de
 	close(pmonitor->m_sendfd);
Jakub Jelen 132f8f
@@ -1303,6 +1303,10 @@ mm_answer_keyallowed(int sock, Buffer *m
Jan F. Chadima ea97ff
 			break;
Jan F. Chadima ea97ff
 		}
Jan F. Chadima ea97ff
 	}
Jan F. Chadima ea97ff
+
Jan F. Chadima ea97ff
+	debug3("%s: key %p is %s",
Jan F. Chadima ea97ff
+	    __func__, key, allowed ? "allowed" : "not allowed");
Jan F. Chadima ea97ff
+
Jan F. Chadima ea97ff
 	if (key != NULL)
Jan F. Chadima ea97ff
 		key_free(key);
Jan F. Chadima ea97ff
 
Jakub Jelen 132f8f
@@ -1324,9 +1328,6 @@ mm_answer_keyallowed(int sock, Buffer *m
Petr Lautrbach 84822b
 		free(chost);
Jan F. Chadima ea97ff
 	}
Jan F. Chadima ea97ff
 
Jan F. Chadima ea97ff
-	debug3("%s: key %p is %s",
Jan F. Chadima ea97ff
-	    __func__, key, allowed ? "allowed" : "not allowed");
Jan F. Chadima ea97ff
-
Jan F. Chadima ea97ff
 	buffer_clear(m);
Jan F. Chadima ea97ff
 	buffer_put_int(m, allowed);
Jan F. Chadima ea97ff
 	buffer_put_int(m, forced_command != NULL);
Jakub Jelen 132f8f
diff -up openssh-6.8p1/monitor_wrap.c.coverity openssh-6.8p1/monitor_wrap.c
Jakub Jelen 132f8f
--- openssh-6.8p1/monitor_wrap.c.coverity	2015-03-18 17:21:51.888264849 +0100
Jakub Jelen 132f8f
+++ openssh-6.8p1/monitor_wrap.c	2015-03-18 17:21:51.897264831 +0100
Jakub Jelen 132f8f
@@ -533,10 +533,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 132f8f
diff -up openssh-6.8p1/openbsd-compat/bindresvport.c.coverity openssh-6.8p1/openbsd-compat/bindresvport.c
Jakub Jelen 132f8f
--- openssh-6.8p1/openbsd-compat/bindresvport.c.coverity	2015-03-17 06:49:20.000000000 +0100
Jakub Jelen 132f8f
+++ openssh-6.8p1/openbsd-compat/bindresvport.c	2015-03-18 17:21:51.897264831 +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 132f8f
diff -up openssh-6.8p1/openbsd-compat/port-linux.h.coverity openssh-6.8p1/openbsd-compat/port-linux.h
Jakub Jelen 132f8f
--- openssh-6.8p1/openbsd-compat/port-linux.h.coverity	2015-03-18 17:21:51.861264906 +0100
Jakub Jelen 132f8f
+++ openssh-6.8p1/openbsd-compat/port-linux.h	2015-03-18 17:21:51.897264831 +0100
Jakub Jelen 580f98
@@ -37,4 +37,6 @@ void oom_adjust_restore(void);
Jakub Jelen 580f98
 void oom_adjust_setup(void);
Jakub Jelen 580f98
 #endif
Jakub Jelen 580f98
 
Jakub Jelen 580f98
+void linux_seed(void);
Jakub Jelen 580f98
+
Jakub Jelen 580f98
 #endif /* ! _PORT_LINUX_H */
Jakub Jelen 132f8f
diff -up openssh-6.8p1/pam_ssh_agent_auth-0.9.3/pam_user_key_allowed2.c.coverity openssh-6.8p1/pam_ssh_agent_auth-0.9.3/pam_user_key_allowed2.c
Jakub Jelen 132f8f
--- openssh-6.8p1/pam_ssh_agent_auth-0.9.3/pam_user_key_allowed2.c.coverity	2015-03-18 17:21:51.788265059 +0100
Jakub Jelen 132f8f
+++ openssh-6.8p1/pam_ssh_agent_auth-0.9.3/pam_user_key_allowed2.c	2015-03-18 17:21:51.898264829 +0100
Jakub Jelen 132f8f
@@ -87,7 +87,7 @@ pam_user_key_allowed2(struct passwd *pw,
Jakub Jelen 580f98
 	found = key_new(key->type);
Jakub Jelen 580f98
 
Jakub Jelen 580f98
 	while (read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) {
Jakub Jelen 580f98
-		char *cp, *key_options = NULL;
Jakub Jelen 580f98
+		char *cp = NULL;
Jakub Jelen 580f98
 
Jakub Jelen 580f98
 		/* Skip leading whitespace, empty and comment lines. */
Jakub Jelen 580f98
 		for (cp = line; *cp == ' ' || *cp == '\t'; cp++)
Jakub Jelen 132f8f
@@ -99,7 +99,6 @@ pam_user_key_allowed2(struct passwd *pw,
Jakub Jelen 580f98
 			/* no key?  check if there are options for this key */
Jakub Jelen 580f98
 			int quoted = 0;
Jakub Jelen 580f98
 			verbose("user_key_allowed: check options: '%s'", cp);
Jakub Jelen 580f98
-			key_options = cp;
Jakub Jelen 580f98
 			for (; *cp && (quoted || (*cp != ' ' && *cp != '\t')); cp++) {
Jakub Jelen 580f98
 				if (*cp == '\\' && cp[1] == '"')
Jakub Jelen 580f98
 					cp++;	/* Skip both */
Jakub Jelen 132f8f
diff -up openssh-6.8p1/pam_ssh_agent_auth-0.9.3/userauth_pubkey_from_id.c.coverity openssh-6.8p1/pam_ssh_agent_auth-0.9.3/userauth_pubkey_from_id.c
Jakub Jelen 132f8f
--- openssh-6.8p1/pam_ssh_agent_auth-0.9.3/userauth_pubkey_from_id.c.coverity	2015-03-18 17:21:51.786265063 +0100
Jakub Jelen 132f8f
+++ openssh-6.8p1/pam_ssh_agent_auth-0.9.3/userauth_pubkey_from_id.c	2015-03-18 17:21:51.898264829 +0100
Jakub Jelen 580f98
@@ -89,8 +89,7 @@ userauth_pubkey_from_id(Identity * id)
Jakub Jelen 580f98
         authenticated = 1;
Jakub Jelen 580f98
 
Jakub Jelen 580f98
   user_auth_clean_exit:
Jakub Jelen 580f98
-    if(&b != NULL)
Jakub Jelen 580f98
-        buffer_free(&b);
Jakub Jelen 580f98
+    buffer_free(&b);
Jakub Jelen 580f98
     if(sig != NULL)
Jakub Jelen 580f98
         free(sig);
Jakub Jelen 580f98
     if(pkblob != NULL)
Jakub Jelen 132f8f
diff -up openssh-6.8p1/scp.c.coverity openssh-6.8p1/scp.c
Jakub Jelen 132f8f
--- openssh-6.8p1/scp.c.coverity	2015-03-18 17:21:51.868264891 +0100
Jakub Jelen 132f8f
+++ openssh-6.8p1/scp.c	2015-03-18 17:21:58.281251460 +0100
Jakub Jelen 132f8f
@@ -156,7 +156,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 132f8f
diff -up openssh-6.8p1/servconf.c.coverity openssh-6.8p1/servconf.c
Jakub Jelen 132f8f
--- openssh-6.8p1/servconf.c.coverity	2015-03-18 17:21:51.893264839 +0100
Jakub Jelen 132f8f
+++ openssh-6.8p1/servconf.c	2015-03-18 17:21:58.281251460 +0100
Jakub Jelen 132f8f
@@ -1475,7 +1475,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 132f8f
@@ -1566,8 +1566,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 132f8f
diff -up openssh-6.8p1/serverloop.c.coverity openssh-6.8p1/serverloop.c
Jakub Jelen 132f8f
--- openssh-6.8p1/serverloop.c.coverity	2015-03-17 06:49:20.000000000 +0100
Jakub Jelen 132f8f
+++ openssh-6.8p1/serverloop.c	2015-03-18 17:28:45.616436080 +0100
Jan F. Chadima 3b545b
@@ -147,13 +147,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
Jan F. Chadima 3b545b
@@ -161,8 +161,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)
Jan F. Chadima 3b545b
 			debug2("notify_done: reading");
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jakub Jelen 132f8f
@@ -337,7 +337,7 @@ wait_until_can_do_something(fd_set **rea
Jan F. Chadima 3b545b
 		 * If we have buffered data, try to write some of that data
Jan F. Chadima 3b545b
 		 * to the program.
Jan F. Chadima 3b545b
 		 */
Jan F. Chadima 3b545b
-		if (fdin != -1 && buffer_len(&stdin_buffer) > 0)
Jan F. Chadima 3b545b
+		if (fdin >= 0 && buffer_len(&stdin_buffer) > 0)
Jan F. Chadima 3b545b
 			FD_SET(fdin, *writesetp);
Jan F. Chadima 3b545b
 	}
Jan F. Chadima 3b545b
 	notify_prepare(*readsetp);
Petr Lautrbach 44f0ac
@@ -477,7 +477,7 @@ process_output(fd_set *writeset)
Jan F. Chadima 3b545b
 	int len;
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 	/* Write buffered data to program stdin. */
Jan F. Chadima 3b545b
-	if (!compat20 && fdin != -1 && FD_ISSET(fdin, writeset)) {
Jan F. Chadima 3b545b
+	if (!compat20 && fdin >= 0 && FD_ISSET(fdin, writeset)) {
Jan F. Chadima 3b545b
 		data = buffer_ptr(&stdin_buffer);
Jan F. Chadima 3b545b
 		dlen = buffer_len(&stdin_buffer);
Jan F. Chadima 3b545b
 		len = write(fdin, data, dlen);
Jakub Jelen 132f8f
@@ -590,7 +590,7 @@ server_loop(pid_t pid, int fdin_arg, int
Jan F. Chadima 3b545b
 	set_nonblock(fdin);
Jan F. Chadima 3b545b
 	set_nonblock(fdout);
Jan F. Chadima 3b545b
 	/* we don't have stderr for interactive terminal sessions, see below */
Jan F. Chadima 3b545b
-	if (fderr != -1)
Jan F. Chadima 3b545b
+	if (fderr >= 0)
Jan F. Chadima 3b545b
 		set_nonblock(fderr);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 	if (!(datafellows & SSH_BUG_IGNOREMSG) && isatty(fdin))
Jakub Jelen 132f8f
@@ -614,7 +614,7 @@ server_loop(pid_t pid, int fdin_arg, int
Jan F. Chadima 3b545b
 	max_fd = MAX(connection_in, connection_out);
Jan F. Chadima 3b545b
 	max_fd = MAX(max_fd, fdin);
Jan F. Chadima 3b545b
 	max_fd = MAX(max_fd, fdout);
Jan F. Chadima 3b545b
-	if (fderr != -1)
Jan F. Chadima 3b545b
+	if (fderr >= 0)
Jan F. Chadima 3b545b
 		max_fd = MAX(max_fd, fderr);
Jan F. Chadima 3b545b
 #endif
Jan F. Chadima 3b545b
 
Jakub Jelen 132f8f
@@ -644,7 +644,7 @@ server_loop(pid_t pid, int fdin_arg, int
Jan F. Chadima 3b545b
 		 * If we have received eof, and there is no more pending
Jan F. Chadima 3b545b
 		 * input data, cause a real eof by closing fdin.
Jan F. Chadima 3b545b
 		 */
Jan F. Chadima 3b545b
-		if (stdin_eof && fdin != -1 && buffer_len(&stdin_buffer) == 0) {
Jan F. Chadima 3b545b
+		if (stdin_eof && fdin >= 0 && buffer_len(&stdin_buffer) == 0) {
Jan F. Chadima 3b545b
 			if (fdin != fdout)
Jan F. Chadima 3b545b
 				close(fdin);
Jan F. Chadima 3b545b
 			else
Jakub Jelen 132f8f
@@ -740,15 +740,15 @@ server_loop(pid_t pid, int fdin_arg, int
Jan F. Chadima 3b545b
 	buffer_free(&stderr_buffer);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 	/* Close the file descriptors. */
Jan F. Chadima 3b545b
-	if (fdout != -1)
Jan F. Chadima 3b545b
+	if (fdout >= 0)
Jan F. Chadima 3b545b
 		close(fdout);
Jan F. Chadima 3b545b
 	fdout = -1;
Jan F. Chadima 3b545b
 	fdout_eof = 1;
Jan F. Chadima 3b545b
-	if (fderr != -1)
Jan F. Chadima 3b545b
+	if (fderr >= 0)
Jan F. Chadima 3b545b
 		close(fderr);
Jan F. Chadima 3b545b
 	fderr = -1;
Jan F. Chadima 3b545b
 	fderr_eof = 1;
Jan F. Chadima 3b545b
-	if (fdin != -1)
Jan F. Chadima 3b545b
+	if (fdin >= 0)
Jan F. Chadima 3b545b
 		close(fdin);
Jan F. Chadima 3b545b
 	fdin = -1;
Jan F. Chadima 3b545b
 
Jakub Jelen 132f8f
@@ -950,7 +950,7 @@ server_input_window_size(int type, u_int
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 	debug("Window change received.");
Jan F. Chadima 3b545b
 	packet_check_eom();
Jan F. Chadima 3b545b
-	if (fdin != -1)
Jan F. Chadima 3b545b
+	if (fdin >= 0)
Jan F. Chadima 3b545b
 		pty_change_window_size(fdin, row, col, xpixel, ypixel);
Jakub Jelen 132f8f
 	return 0;
Jan F. Chadima 3b545b
 }
Jakub Jelen 132f8f
@@ -1043,7 +1043,7 @@ server_request_tun(void)
Jan F. Chadima 3b545b
 	}
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 	tun = packet_get_int();
Jan F. Chadima 3b545b
-	if (forced_tun_device != -1) {
Jan F. Chadima 3b545b
+	if (forced_tun_device >= 0) {
Jan F. Chadima 3b545b
 		if (tun != SSH_TUNID_ANY && forced_tun_device != tun)
Jan F. Chadima 3b545b
 			goto done;
Jan F. Chadima 3b545b
 		tun = forced_tun_device;
Jakub Jelen 132f8f
diff -up openssh-6.8p1/sftp.c.coverity openssh-6.8p1/sftp.c
Jakub Jelen 132f8f
--- openssh-6.8p1/sftp.c.coverity	2015-03-17 06:49:20.000000000 +0100
Jakub Jelen 132f8f
+++ openssh-6.8p1/sftp.c	2015-03-18 17:21:58.283251456 +0100
Jakub Jelen 132f8f
@@ -223,7 +223,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 132f8f
@@ -335,7 +335,7 @@ local_do_ls(const char *args)
Petr Lautrbach 84822b
 
Petr Lautrbach 84822b
 /* Strip one path (usually the pwd) from the start of another */
Petr Lautrbach 84822b
 static char *
Petr Lautrbach 84822b
-path_strip(char *path, char *strip)
Petr Lautrbach 84822b
+path_strip(const char *path, const char *strip)
Petr Lautrbach 84822b
 {
Petr Lautrbach 84822b
 	size_t len;
Petr Lautrbach 84822b
 
Jakub Jelen 132f8f
@@ -353,7 +353,7 @@ path_strip(char *path, char *strip)
Petr Lautrbach 84822b
 }
Petr Lautrbach 84822b
 
Petr Lautrbach 84822b
 static char *
Petr Lautrbach 84822b
-make_absolute(char *p, char *pwd)
Petr Lautrbach 84822b
+make_absolute(char *p, const char *pwd)
Petr Lautrbach 84822b
 {
Petr Lautrbach 84822b
 	char *abs_str;
Petr Lautrbach 84822b
 
Jakub Jelen 132f8f
@@ -551,7 +551,7 @@ parse_no_flags(const char *cmd, char **a
Petr Lautrbach 84822b
 }
Petr Lautrbach 84822b
 
Petr Lautrbach 84822b
 static int
Petr Lautrbach 84822b
-is_dir(char *path)
Petr Lautrbach 84822b
+is_dir(const char *path)
Petr Lautrbach 84822b
 {
Petr Lautrbach 84822b
 	struct stat sb;
Petr Lautrbach 84822b
 
Jakub Jelen 132f8f
@@ -563,7 +563,7 @@ is_dir(char *path)
Petr Lautrbach 84822b
 }
Petr Lautrbach 84822b
 
Petr Lautrbach 84822b
 static int
Petr Lautrbach 84822b
-remote_is_dir(struct sftp_conn *conn, char *path)
Petr Lautrbach 84822b
+remote_is_dir(struct sftp_conn *conn, const char *path)
Petr Lautrbach 84822b
 {
Petr Lautrbach 84822b
 	Attrib *a;
Petr Lautrbach 84822b
 
Jakub Jelen 132f8f
@@ -577,7 +577,7 @@ remote_is_dir(struct sftp_conn *conn, ch
Petr Lautrbach 84822b
 
Petr Lautrbach 84822b
 /* Check whether path returned from glob(..., GLOB_MARK, ...) is a directory */
Petr Lautrbach 84822b
 static int
Petr Lautrbach 84822b
-pathname_is_dir(char *pathname)
Petr Lautrbach 84822b
+pathname_is_dir(const char *pathname)
Petr Lautrbach 84822b
 {
Petr Lautrbach 84822b
 	size_t l = strlen(pathname);
Petr Lautrbach 84822b
 
Jakub Jelen 132f8f
@@ -585,7 +585,7 @@ pathname_is_dir(char *pathname)
Petr Lautrbach 84822b
 }
Petr Lautrbach 84822b
 
Petr Lautrbach 84822b
 static int
Petr Lautrbach 84822b
-process_get(struct sftp_conn *conn, char *src, char *dst, char *pwd,
Petr Lautrbach 84822b
+process_get(struct sftp_conn *conn, const char *src, const char *dst, const char *pwd,
Petr Lautrbach 44f0ac
     int pflag, int rflag, int resume, int fflag)
Petr Lautrbach 84822b
 {
Petr Lautrbach 84822b
 	char *abs_src = NULL;
Jakub Jelen 132f8f
@@ -669,7 +669,7 @@ out:
Petr Lautrbach 84822b
 }
Petr Lautrbach 84822b
 
Petr Lautrbach 84822b
 static int
Petr Lautrbach 84822b
-process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd,
Petr Lautrbach 84822b
+process_put(struct sftp_conn *conn, const char *src, const char *dst, const char *pwd,
Jakub Jelen 580f98
     int pflag, int rflag, int resume, int fflag)
Petr Lautrbach 84822b
 {
Petr Lautrbach 84822b
 	char *tmp_dst = NULL;
Jakub Jelen 132f8f
@@ -779,7 +779,7 @@ sdirent_comp(const void *aa, const void
Petr Lautrbach 84822b
 
Petr Lautrbach 84822b
 /* sftp ls.1 replacement for directories */
Petr Lautrbach 84822b
 static int
Petr Lautrbach 84822b
-do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
Petr Lautrbach 84822b
+do_ls_dir(struct sftp_conn *conn, const char *path, const char *strip_path, int lflag)
Petr Lautrbach 84822b
 {
Petr Lautrbach 84822b
 	int n;
Petr Lautrbach 84822b
 	u_int c = 1, colspace = 0, columns = 1;
Jakub Jelen 132f8f
@@ -864,7 +864,7 @@ do_ls_dir(struct sftp_conn *conn, char *
Petr Lautrbach 84822b
 
Petr Lautrbach 84822b
 /* sftp ls.1 replacement which handles path globs */
Petr Lautrbach 84822b
 static int
Petr Lautrbach 84822b
-do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
Petr Lautrbach 84822b
+do_globbed_ls(struct sftp_conn *conn, const char *path, const char *strip_path,
Petr Lautrbach 84822b
     int lflag)
Petr Lautrbach 84822b
 {
Petr Lautrbach 84822b
 	char *fname, *lname;
Jakub Jelen 132f8f
@@ -949,7 +949,7 @@ do_globbed_ls(struct sftp_conn *conn, ch
Petr Lautrbach 84822b
 }
Petr Lautrbach 84822b
 
Petr Lautrbach 84822b
 static int
Petr Lautrbach 84822b
-do_df(struct sftp_conn *conn, char *path, int hflag, int iflag)
Petr Lautrbach 84822b
+do_df(struct sftp_conn *conn, const char *path, int hflag, int iflag)
Petr Lautrbach 84822b
 {
Petr Lautrbach 84822b
 	struct sftp_statvfs st;
Petr Lautrbach 84822b
 	char s_used[FMT_SCALED_STRSIZE];
Jakub Jelen 132f8f
diff -up openssh-6.8p1/ssh-agent.c.coverity openssh-6.8p1/ssh-agent.c
Jakub Jelen 132f8f
--- openssh-6.8p1/ssh-agent.c.coverity	2015-03-17 06:49:20.000000000 +0100
Jakub Jelen 132f8f
+++ openssh-6.8p1/ssh-agent.c	2015-03-18 17:21:58.284251454 +0100
Jakub Jelen 132f8f
@@ -1166,8 +1166,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
 
Jan F. Chadima ea97ff
 #if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
Jan F. Chadima ea97ff
 	/* Disable ptrace on Linux without sgid bit */
Jakub Jelen 132f8f
diff -up openssh-6.8p1/sshd.c.coverity openssh-6.8p1/sshd.c
Jakub Jelen 132f8f
--- openssh-6.8p1/sshd.c.coverity	2015-03-18 17:21:51.893264839 +0100
Jakub Jelen 132f8f
+++ openssh-6.8p1/sshd.c	2015-03-18 17:21:58.284251454 +0100
Jakub Jelen 132f8f
@@ -778,8 +778,10 @@ privsep_preauth(Authctxt *authctxt)
Jan F. Chadima cff1d0
 		if (getuid() == 0 || geteuid() == 0)
Jan F. Chadima cff1d0
 			privsep_preauth_child();
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 132f8f
@@ -1518,6 +1520,9 @@ server_accept_loop(int *sock_in, int *so
Jan F. Chadima 3b545b
 		if (num_listen_socks < 0)
Jan F. Chadima 3b545b
 			break;
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
 
Jan F. Chadima 3b545b
 
Jakub Jelen 132f8f
diff -up openssh-6.8p1/sshkey.c.coverity openssh-6.8p1/sshkey.c
Jakub Jelen 132f8f
--- openssh-6.8p1/sshkey.c.coverity	2015-03-18 17:21:58.285251452 +0100
Jakub Jelen 132f8f
+++ openssh-6.8p1/sshkey.c	2015-03-18 17:45:32.232705363 +0100
Jakub Jelen 132f8f
@@ -58,6 +58,7 @@
Jakub Jelen 580f98
 #include "digest.h"
Jakub Jelen 580f98
 #define SSHKEY_INTERNAL
Jakub Jelen 580f98
 #include "sshkey.h"
Jakub Jelen 580f98
+#include "log.h"
Jakub Jelen 132f8f
 #include "match.h"
Jakub Jelen 580f98
 
Jakub Jelen 580f98
 /* openssh private key file format */
Jakub Jelen 576cdf
diff --git a/sshd.c b/sshd.c
Jakub Jelen 576cdf
index 6ff8f6f..2f2fcf8 100644
Jakub Jelen 576cdf
--- a/sshd.c
Jakub Jelen 576cdf
+++ b/sshd.c
Jakub Jelen 576cdf
@@ -1548,6 +1548,7 @@ main(int ac, char **av)
Jakub Jelen 576cdf
 	int keytype;
Jakub Jelen 576cdf
 	Authctxt *authctxt;
Jakub Jelen 576cdf
 	struct connection_info *connection_info = get_connection_info(0, 0);
Jakub Jelen 576cdf
+	char *addr = NULL;
Jakub Jelen 576cdf
 
Jakub Jelen 576cdf
 #ifdef HAVE_SECUREWARE
Jakub Jelen 576cdf
 	(void)set_auth_parameters(ac, av);
Jakub Jelen 576cdf
@@ -2261,7 +2262,8 @@ main(int ac, char **av)
Jakub Jelen 576cdf
 	/* Log the connection. */
Jakub Jelen 576cdf
 	verbose("Connection from %s port %d on %s port %d",
Jakub Jelen 576cdf
 	    remote_ip, remote_port,
Jakub Jelen 576cdf
-	    get_local_ipaddr(sock_in), get_local_port());
Jakub Jelen 576cdf
+	    (addr = get_local_ipaddr(sock_in)), get_local_port());
Jakub Jelen 576cdf
+	free(addr);
Jakub Jelen 576cdf
 
Jakub Jelen 576cdf
 	/*
Jakub Jelen 576cdf
 	 * We don't want to listen forever unless the other side