vishalmishra434 / rpms / openssh

Forked from rpms/openssh a month ago
Clone
017ff1
diff --git a/auth-pam.c b/auth-pam.c
017ff1
index cd1a775..690711e 100644
017ff1
--- a/auth-pam.c
017ff1
+++ b/auth-pam.c
017ff1
@@ -216,7 +216,12 @@ pthread_join(sp_pthread_t thread, void **value)
f09e2e
 	if (sshpam_thread_status != -1)
f09e2e
 		return (sshpam_thread_status);
f09e2e
 	signal(SIGCHLD, sshpam_oldsig);
f09e2e
-	waitpid(thread, &status, 0);
f09e2e
+	while (waitpid(thread, &status, 0) < 0) {                     
f09e2e
+		if (errno == EINTR)                                
f09e2e
+			continue;
f09e2e
+		fatal("%s: waitpid: %s", __func__,         
f09e2e
+				strerror(errno));                      
f09e2e
+	}
f09e2e
 	return (status);
f09e2e
 }
f09e2e
 #endif
017ff1
diff --git a/channels.c b/channels.c
017ff1
index af3fdc2..39c9f89 100644
017ff1
--- a/channels.c
017ff1
+++ b/channels.c
017ff1
@@ -233,11 +233,11 @@ channel_register_fds(Channel *c, int rfd, int wfd, int efd,
f09e2e
 	channel_max_fd = MAX(channel_max_fd, wfd);
f09e2e
 	channel_max_fd = MAX(channel_max_fd, efd);
f09e2e
 
f09e2e
-	if (rfd != -1)
f09e2e
+	if (rfd >= 0)
f09e2e
 		fcntl(rfd, F_SETFD, FD_CLOEXEC);
f09e2e
-	if (wfd != -1 && wfd != rfd)
f09e2e
+	if (wfd >= 0 && wfd != rfd)
f09e2e
 		fcntl(wfd, F_SETFD, FD_CLOEXEC);
f09e2e
-	if (efd != -1 && efd != rfd && efd != wfd)
f09e2e
+	if (efd >= 0 && efd != rfd && efd != wfd)
f09e2e
 		fcntl(efd, F_SETFD, FD_CLOEXEC);
f09e2e
 
f09e2e
 	c->rfd = rfd;
017ff1
@@ -255,11 +255,11 @@ channel_register_fds(Channel *c, int rfd, int wfd, int efd,
f09e2e
 
f09e2e
 	/* enable nonblocking mode */
f09e2e
 	if (nonblock) {
f09e2e
-		if (rfd != -1)
f09e2e
+		if (rfd >= 0)
f09e2e
 			set_nonblock(rfd);
f09e2e
-		if (wfd != -1)
f09e2e
+		if (wfd >= 0)
f09e2e
 			set_nonblock(wfd);
f09e2e
-		if (efd != -1)
f09e2e
+		if (efd >= 0)
f09e2e
 			set_nonblock(efd);
f09e2e
 	}
f09e2e
 }
017ff1
diff --git a/clientloop.c b/clientloop.c
017ff1
index 9c60108..d372b53 100644
017ff1
--- a/clientloop.c
017ff1
+++ b/clientloop.c
017ff1
@@ -2081,14 +2081,15 @@ client_input_global_request(int type, u_int32_t seq, void *ctxt)
f09e2e
 	char *rtype;
f09e2e
 	int want_reply;
f09e2e
 	int success = 0;
f09e2e
+/* success is still 0 the packet is allways SSH2_MSG_REQUEST_FAILURE, isn't it? */
f09e2e
 
f09e2e
 	rtype = packet_get_string(NULL);
f09e2e
 	want_reply = packet_get_char();
f09e2e
 	debug("client_input_global_request: rtype %s want_reply %d",
f09e2e
 	    rtype, want_reply);
f09e2e
 	if (want_reply) {
f09e2e
-		packet_start(success ?
f09e2e
-		    SSH2_MSG_REQUEST_SUCCESS : SSH2_MSG_REQUEST_FAILURE);
f09e2e
+		packet_start(/*success ?
f09e2e
+		    SSH2_MSG_REQUEST_SUCCESS :*/ SSH2_MSG_REQUEST_FAILURE);
f09e2e
 		packet_send();
f09e2e
 		packet_write_wait();
f09e2e
 	}
017ff1
diff --git a/key.c b/key.c
017ff1
index a2050f6..6487d81 100644
017ff1
--- a/key.c
017ff1
+++ b/key.c
017ff1
@@ -880,8 +880,10 @@ key_read(Key *ret, char **cpp)
f09e2e
 		success = 1;
f09e2e
 /*XXXX*/
f09e2e
 		key_free(k);
f09e2e
+/*XXXX
f09e2e
 		if (success != 1)
f09e2e
 			break;
f09e2e
+XXXX*/
f09e2e
 		/* advance cp: skip whitespace and data */
f09e2e
 		while (*cp == ' ' || *cp == '\t')
f09e2e
 			cp++;
017ff1
diff --git a/monitor.c b/monitor.c
017ff1
index 3ff62b0..70b9b4c 100644
017ff1
--- a/monitor.c
017ff1
+++ b/monitor.c
017ff1
@@ -472,7 +472,7 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
f09e2e
 	mm_get_keystate(pmonitor);
f09e2e
 
f09e2e
 	/* Drain any buffered messages from the child */
f09e2e
-	while (pmonitor->m_log_recvfd != -1 && monitor_read_log(pmonitor) == 0)
f09e2e
+	while (pmonitor->m_log_recvfd >= 0 && monitor_read_log(pmonitor) == 0)
f09e2e
 		;
f09e2e
 
f09e2e
 	close(pmonitor->m_sendfd);
017ff1
@@ -1254,6 +1254,10 @@ mm_answer_keyallowed(int sock, Buffer *m)
f09e2e
 			break;
f09e2e
 		}
f09e2e
 	}
f09e2e
+
f09e2e
+	debug3("%s: key %p is %s",
f09e2e
+	    __func__, key, allowed ? "allowed" : "not allowed");
f09e2e
+
f09e2e
 	if (key != NULL)
f09e2e
 		key_free(key);
f09e2e
 
017ff1
@@ -1275,9 +1279,6 @@ mm_answer_keyallowed(int sock, Buffer *m)
f09e2e
 		free(chost);
f09e2e
 	}
f09e2e
 
f09e2e
-	debug3("%s: key %p is %s",
f09e2e
-	    __func__, key, allowed ? "allowed" : "not allowed");
f09e2e
-
f09e2e
 	buffer_clear(m);
f09e2e
 	buffer_put_int(m, allowed);
f09e2e
 	buffer_put_int(m, forced_command != NULL);
017ff1
diff --git a/monitor_wrap.c b/monitor_wrap.c
017ff1
index 6df236a..93f6535 100644
017ff1
--- a/monitor_wrap.c
017ff1
+++ b/monitor_wrap.c
017ff1
@@ -743,10 +743,10 @@ mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen)
f09e2e
 	if ((tmp1 = dup(pmonitor->m_recvfd)) == -1 ||
f09e2e
 	    (tmp2 = dup(pmonitor->m_recvfd)) == -1) {
f09e2e
 		error("%s: cannot allocate fds for pty", __func__);
f09e2e
-		if (tmp1 > 0)
f09e2e
+		if (tmp1 >= 0)
f09e2e
 			close(tmp1);
f09e2e
-		if (tmp2 > 0)
f09e2e
-			close(tmp2);
f09e2e
+		/*DEAD CODE if (tmp2 >= 0)
f09e2e
+			close(tmp2);*/
f09e2e
 		return 0;
f09e2e
 	}
f09e2e
 	close(tmp1);
017ff1
diff --git a/openbsd-compat/bindresvport.c b/openbsd-compat/bindresvport.c
017ff1
index c89f214..80115c2 100644
017ff1
--- a/openbsd-compat/bindresvport.c
017ff1
+++ b/openbsd-compat/bindresvport.c
017ff1
@@ -58,7 +58,7 @@ bindresvport_sa(int sd, struct sockaddr *sa)
f09e2e
 	struct sockaddr_in6 *in6;
f09e2e
 	u_int16_t *portp;
f09e2e
 	u_int16_t port;
f09e2e
-	socklen_t salen;
f09e2e
+	socklen_t salen = sizeof(struct sockaddr_storage);
f09e2e
 	int i;
f09e2e
 
f09e2e
 	if (sa == NULL) {
017ff1
diff --git a/packet.c b/packet.c
017ff1
index f5b122b..1305e87 100644
017ff1
--- a/packet.c
017ff1
+++ b/packet.c
017ff1
@@ -1234,6 +1234,7 @@ packet_read_poll1(void)
f09e2e
 		case DEATTACK_DETECTED:
f09e2e
 			packet_disconnect("crc32 compensation attack: "
f09e2e
 			    "network attack detected");
f09e2e
+			break;
f09e2e
 		case DEATTACK_DOS_DETECTED:
f09e2e
 			packet_disconnect("deattack denial of "
f09e2e
 			    "service detected");
017ff1
diff --git a/progressmeter.c b/progressmeter.c
017ff1
index bbbc706..ae6d1aa 100644
017ff1
--- a/progressmeter.c
017ff1
+++ b/progressmeter.c
f09e2e
@@ -65,7 +65,7 @@ static void update_progress_meter(int);
f09e2e
 
f09e2e
 static time_t start;		/* start progress */
f09e2e
 static time_t last_update;	/* last progress update */
f09e2e
-static char *file;		/* name of the file being transferred */
f09e2e
+static const char *file;	/* name of the file being transferred */
017ff1
 static off_t start_pos;		/* initial position of transfer */
f09e2e
 static off_t end_pos;		/* ending position of transfer */
f09e2e
 static off_t cur_pos;		/* transfer position as of last refresh */
017ff1
@@ -248,7 +248,7 @@ update_progress_meter(int ignore)
f09e2e
 }
f09e2e
 
f09e2e
 void
f09e2e
-start_progress_meter(char *f, off_t filesize, off_t *ctr)
f09e2e
+start_progress_meter(const char *f, off_t filesize, off_t *ctr)
f09e2e
 {
f09e2e
 	start = last_update = monotime();
f09e2e
 	file = f;
017ff1
diff --git a/progressmeter.h b/progressmeter.h
017ff1
index 10bab99..e9ca8f0 100644
017ff1
--- a/progressmeter.h
017ff1
+++ b/progressmeter.h
f09e2e
@@ -23,5 +23,5 @@
f09e2e
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
f09e2e
  */
f09e2e
 
f09e2e
-void	start_progress_meter(char *, off_t, off_t *);
f09e2e
+void	start_progress_meter(const char *, off_t, off_t *);
f09e2e
 void	stop_progress_meter(void);
017ff1
diff --git a/scp.c b/scp.c
017ff1
index 1178a07..d9bc016 100644
017ff1
--- a/scp.c
017ff1
+++ b/scp.c
f09e2e
@@ -155,7 +155,7 @@ killchild(int signo)
f09e2e
 {
f09e2e
 	if (do_cmd_pid > 1) {
f09e2e
 		kill(do_cmd_pid, signo ? signo : SIGTERM);
f09e2e
-		waitpid(do_cmd_pid, NULL, 0);
f09e2e
+		(void) waitpid(do_cmd_pid, NULL, 0);
f09e2e
 	}
f09e2e
 
f09e2e
 	if (signo)
017ff1
diff --git a/servconf.c b/servconf.c
017ff1
index 3839928..d482e79 100644
017ff1
--- a/servconf.c
017ff1
+++ b/servconf.c
017ff1
@@ -1382,7 +1382,7 @@ process_server_config_line(ServerOptions *options, char *line,
f09e2e
 			fatal("%s line %d: Missing subsystem name.",
f09e2e
 			    filename, linenum);
f09e2e
 		if (!*activep) {
f09e2e
-			arg = strdelim(&cp;;
f09e2e
+			/*arg =*/ (void) strdelim(&cp;;
f09e2e
 			break;
f09e2e
 		}
f09e2e
 		for (i = 0; i < options->num_subsystems; i++)
017ff1
@@ -1473,8 +1473,9 @@ process_server_config_line(ServerOptions *options, char *line,
f09e2e
 		if (*activep && *charptr == NULL) {
f09e2e
 			*charptr = tilde_expand_filename(arg, getuid());
f09e2e
 			/* increase optional counter */
f09e2e
-			if (intptr != NULL)
f09e2e
-				*intptr = *intptr + 1;
f09e2e
+			/* DEAD CODE intptr is still NULL ;)
f09e2e
+  			 if (intptr != NULL)
f09e2e
+				*intptr = *intptr + 1; */
f09e2e
 		}
f09e2e
 		break;
f09e2e
 
017ff1
diff --git a/serverloop.c b/serverloop.c
017ff1
index 2f8e3a0..e03bc6c 100644
017ff1
--- a/serverloop.c
017ff1
+++ b/serverloop.c
f09e2e
@@ -147,13 +147,13 @@ notify_setup(void)
f09e2e
 static void
f09e2e
 notify_parent(void)
f09e2e
 {
f09e2e
-	if (notify_pipe[1] != -1)
f09e2e
+	if (notify_pipe[1] >= 0)
f09e2e
 		(void)write(notify_pipe[1], "", 1);
f09e2e
 }
f09e2e
 static void
f09e2e
 notify_prepare(fd_set *readset)
f09e2e
 {
f09e2e
-	if (notify_pipe[0] != -1)
f09e2e
+	if (notify_pipe[0] >= 0)
f09e2e
 		FD_SET(notify_pipe[0], readset);
f09e2e
 }
f09e2e
 static void
f09e2e
@@ -161,8 +161,8 @@ notify_done(fd_set *readset)
f09e2e
 {
f09e2e
 	char c;
f09e2e
 
f09e2e
-	if (notify_pipe[0] != -1 && FD_ISSET(notify_pipe[0], readset))
f09e2e
-		while (read(notify_pipe[0], &c, 1) != -1)
f09e2e
+	if (notify_pipe[0] >= 0 && FD_ISSET(notify_pipe[0], readset))
f09e2e
+		while (read(notify_pipe[0], &c, 1) >= 0)
f09e2e
 			debug2("notify_done: reading");
f09e2e
 }
f09e2e
 
017ff1
@@ -337,7 +337,7 @@ wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp,
f09e2e
 		 * If we have buffered data, try to write some of that data
f09e2e
 		 * to the program.
f09e2e
 		 */
f09e2e
-		if (fdin != -1 && buffer_len(&stdin_buffer) > 0)
f09e2e
+		if (fdin >= 0 && buffer_len(&stdin_buffer) > 0)
f09e2e
 			FD_SET(fdin, *writesetp);
f09e2e
 	}
f09e2e
 	notify_prepare(*readsetp);
017ff1
@@ -477,7 +477,7 @@ process_output(fd_set *writeset)
f09e2e
 	int len;
f09e2e
 
f09e2e
 	/* Write buffered data to program stdin. */
f09e2e
-	if (!compat20 && fdin != -1 && FD_ISSET(fdin, writeset)) {
f09e2e
+	if (!compat20 && fdin >= 0 && FD_ISSET(fdin, writeset)) {
f09e2e
 		data = buffer_ptr(&stdin_buffer);
f09e2e
 		dlen = buffer_len(&stdin_buffer);
f09e2e
 		len = write(fdin, data, dlen);
017ff1
@@ -590,7 +590,7 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
f09e2e
 	set_nonblock(fdin);
f09e2e
 	set_nonblock(fdout);
f09e2e
 	/* we don't have stderr for interactive terminal sessions, see below */
f09e2e
-	if (fderr != -1)
f09e2e
+	if (fderr >= 0)
f09e2e
 		set_nonblock(fderr);
f09e2e
 
f09e2e
 	if (!(datafellows & SSH_BUG_IGNOREMSG) && isatty(fdin))
017ff1
@@ -614,7 +614,7 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
f09e2e
 	max_fd = MAX(connection_in, connection_out);
f09e2e
 	max_fd = MAX(max_fd, fdin);
f09e2e
 	max_fd = MAX(max_fd, fdout);
f09e2e
-	if (fderr != -1)
f09e2e
+	if (fderr >= 0)
f09e2e
 		max_fd = MAX(max_fd, fderr);
f09e2e
 #endif
f09e2e
 
017ff1
@@ -644,7 +644,7 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
f09e2e
 		 * If we have received eof, and there is no more pending
f09e2e
 		 * input data, cause a real eof by closing fdin.
f09e2e
 		 */
f09e2e
-		if (stdin_eof && fdin != -1 && buffer_len(&stdin_buffer) == 0) {
f09e2e
+		if (stdin_eof && fdin >= 0 && buffer_len(&stdin_buffer) == 0) {
f09e2e
 			if (fdin != fdout)
f09e2e
 				close(fdin);
f09e2e
 			else
017ff1
@@ -740,15 +740,15 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
f09e2e
 	buffer_free(&stderr_buffer);
f09e2e
 
f09e2e
 	/* Close the file descriptors. */
f09e2e
-	if (fdout != -1)
f09e2e
+	if (fdout >= 0)
f09e2e
 		close(fdout);
f09e2e
 	fdout = -1;
f09e2e
 	fdout_eof = 1;
f09e2e
-	if (fderr != -1)
f09e2e
+	if (fderr >= 0)
f09e2e
 		close(fderr);
f09e2e
 	fderr = -1;
f09e2e
 	fderr_eof = 1;
f09e2e
-	if (fdin != -1)
f09e2e
+	if (fdin >= 0)
f09e2e
 		close(fdin);
f09e2e
 	fdin = -1;
f09e2e
 
017ff1
@@ -947,7 +947,7 @@ server_input_window_size(int type, u_int32_t seq, void *ctxt)
f09e2e
 
f09e2e
 	debug("Window change received.");
f09e2e
 	packet_check_eom();
f09e2e
-	if (fdin != -1)
f09e2e
+	if (fdin >= 0)
f09e2e
 		pty_change_window_size(fdin, row, col, xpixel, ypixel);
f09e2e
 }
f09e2e
 
017ff1
@@ -1007,7 +1007,7 @@ server_request_tun(void)
f09e2e
 	}
f09e2e
 
f09e2e
 	tun = packet_get_int();
f09e2e
-	if (forced_tun_device != -1) {
f09e2e
+	if (forced_tun_device >= 0) {
f09e2e
 		if (tun != SSH_TUNID_ANY && forced_tun_device != tun)
f09e2e
 			goto done;
f09e2e
 		tun = forced_tun_device;
017ff1
diff --git a/sftp-client.c b/sftp-client.c
017ff1
index 2f5907c..3a2affd 100644
017ff1
--- a/sftp-client.c
017ff1
+++ b/sftp-client.c
017ff1
@@ -151,7 +151,7 @@ get_msg(struct sftp_conn *conn, Buffer *m)
f09e2e
 }
f09e2e
 
f09e2e
 static void
f09e2e
-send_string_request(struct sftp_conn *conn, u_int id, u_int code, char *s,
f09e2e
+send_string_request(struct sftp_conn *conn, u_int id, u_int code, const char *s,
f09e2e
     u_int len)
f09e2e
 {
f09e2e
 	Buffer msg;
017ff1
@@ -167,7 +167,7 @@ send_string_request(struct sftp_conn *conn, u_int id, u_int code, char *s,
f09e2e
 
f09e2e
 static void
f09e2e
 send_string_attrs_request(struct sftp_conn *conn, u_int id, u_int code,
f09e2e
-    char *s, u_int len, Attrib *a)
f09e2e
+    const char *s, u_int len, Attrib *a)
f09e2e
 {
f09e2e
 	Buffer msg;
f09e2e
 
017ff1
@@ -429,7 +429,7 @@ sftp_proto_version(struct sftp_conn *conn)
f09e2e
 }
f09e2e
 
f09e2e
 int
f09e2e
-do_close(struct sftp_conn *conn, char *handle, u_int handle_len)
f09e2e
+do_close(struct sftp_conn *conn, const char *handle, u_int handle_len)
f09e2e
 {
f09e2e
 	u_int id, status;
f09e2e
 	Buffer msg;
017ff1
@@ -454,7 +454,7 @@ do_close(struct sftp_conn *conn, char *handle, u_int handle_len)
f09e2e
 
f09e2e
 
f09e2e
 static int
017ff1
-do_lsreaddir(struct sftp_conn *conn, char *path, int print_flag,
017ff1
+do_lsreaddir(struct sftp_conn *conn, const char *path, int print_flag,
f09e2e
     SFTP_DIRENT ***dir)
f09e2e
 {
f09e2e
 	Buffer msg;
017ff1
@@ -577,7 +577,7 @@ do_lsreaddir(struct sftp_conn *conn, char *path, int print_flag,
f09e2e
 }
f09e2e
 
f09e2e
 int
f09e2e
-do_readdir(struct sftp_conn *conn, char *path, SFTP_DIRENT ***dir)
f09e2e
+do_readdir(struct sftp_conn *conn, const char *path, SFTP_DIRENT ***dir)
f09e2e
 {
f09e2e
 	return(do_lsreaddir(conn, path, 0, dir));
f09e2e
 }
017ff1
@@ -597,7 +597,7 @@ void free_sftp_dirents(SFTP_DIRENT **s)
f09e2e
 }
f09e2e
 
f09e2e
 int
f09e2e
-do_rm(struct sftp_conn *conn, char *path)
f09e2e
+do_rm(struct sftp_conn *conn, const char *path)
f09e2e
 {
f09e2e
 	u_int status, id;
f09e2e
 
017ff1
@@ -612,7 +612,7 @@ do_rm(struct sftp_conn *conn, char *path)
f09e2e
 }
f09e2e
 
f09e2e
 int
017ff1
-do_mkdir(struct sftp_conn *conn, char *path, Attrib *a, int print_flag)
017ff1
+do_mkdir(struct sftp_conn *conn, const char *path, Attrib *a, int print_flag)
f09e2e
 {
f09e2e
 	u_int status, id;
f09e2e
 
017ff1
@@ -628,7 +628,7 @@ do_mkdir(struct sftp_conn *conn, char *path, Attrib *a, int print_flag)
f09e2e
 }
f09e2e
 
f09e2e
 int
f09e2e
-do_rmdir(struct sftp_conn *conn, char *path)
f09e2e
+do_rmdir(struct sftp_conn *conn, const char *path)
f09e2e
 {
f09e2e
 	u_int status, id;
f09e2e
 
017ff1
@@ -644,7 +644,7 @@ do_rmdir(struct sftp_conn *conn, char *path)
f09e2e
 }
f09e2e
 
f09e2e
 Attrib *
f09e2e
-do_stat(struct sftp_conn *conn, char *path, int quiet)
f09e2e
+do_stat(struct sftp_conn *conn, const char *path, int quiet)
f09e2e
 {
f09e2e
 	u_int id;
f09e2e
 
017ff1
@@ -658,7 +658,7 @@ do_stat(struct sftp_conn *conn, char *path, int quiet)
f09e2e
 }
f09e2e
 
f09e2e
 Attrib *
f09e2e
-do_lstat(struct sftp_conn *conn, char *path, int quiet)
f09e2e
+do_lstat(struct sftp_conn *conn, const char *path, int quiet)
f09e2e
 {
f09e2e
 	u_int id;
f09e2e
 
017ff1
@@ -679,7 +679,7 @@ do_lstat(struct sftp_conn *conn, char *path, int quiet)
017ff1
 
017ff1
 #ifdef notyet
017ff1
 Attrib *
017ff1
-do_fstat(struct sftp_conn *conn, char *handle, u_int handle_len, int quiet)
017ff1
+do_fstat(struct sftp_conn *conn, const char *handle, u_int handle_len, int quiet)
017ff1
 {
017ff1
 	u_int id;
017ff1
 
017ff1
@@ -692,7 +692,7 @@ do_fstat(struct sftp_conn *conn, char *handle, u_int handle_len, int quiet)
f09e2e
 #endif
f09e2e
 
f09e2e
 int
f09e2e
-do_setstat(struct sftp_conn *conn, char *path, Attrib *a)
f09e2e
+do_setstat(struct sftp_conn *conn, const char *path, Attrib *a)
f09e2e
 {
f09e2e
 	u_int status, id;
f09e2e
 
017ff1
@@ -709,7 +709,7 @@ do_setstat(struct sftp_conn *conn, char *path, Attrib *a)
f09e2e
 }
f09e2e
 
f09e2e
 int
f09e2e
-do_fsetstat(struct sftp_conn *conn, char *handle, u_int handle_len,
f09e2e
+do_fsetstat(struct sftp_conn *conn, const char *handle, u_int handle_len,
f09e2e
     Attrib *a)
f09e2e
 {
f09e2e
 	u_int status, id;
017ff1
@@ -726,7 +726,7 @@ do_fsetstat(struct sftp_conn *conn, char *handle, u_int handle_len,
f09e2e
 }
f09e2e
 
f09e2e
 char *
f09e2e
-do_realpath(struct sftp_conn *conn, char *path)
f09e2e
+do_realpath(struct sftp_conn *conn, const char *path)
f09e2e
 {
f09e2e
 	Buffer msg;
f09e2e
 	u_int type, expected_id, count, id;
017ff1
@@ -775,7 +775,7 @@ do_realpath(struct sftp_conn *conn, char *path)
f09e2e
 }
f09e2e
 
f09e2e
 int
017ff1
-do_rename(struct sftp_conn *conn, char *oldpath, char *newpath,
017ff1
+do_rename(struct sftp_conn *conn, const char *oldpath, const char *newpath,
017ff1
     int force_legacy)
f09e2e
 {
f09e2e
 	Buffer msg;
017ff1
@@ -811,7 +811,7 @@ do_rename(struct sftp_conn *conn, char *oldpath, char *newpath,
f09e2e
 }
f09e2e
 
f09e2e
 int
f09e2e
-do_hardlink(struct sftp_conn *conn, char *oldpath, char *newpath)
f09e2e
+do_hardlink(struct sftp_conn *conn, const char *oldpath, const char *newpath)
f09e2e
 {
f09e2e
 	Buffer msg;
f09e2e
 	u_int status, id;
017ff1
@@ -844,7 +844,7 @@ do_hardlink(struct sftp_conn *conn, char *oldpath, char *newpath)
f09e2e
 }
f09e2e
 
f09e2e
 int
f09e2e
-do_symlink(struct sftp_conn *conn, char *oldpath, char *newpath)
f09e2e
+do_symlink(struct sftp_conn *conn, const char *oldpath, const char *newpath)
f09e2e
 {
f09e2e
 	Buffer msg;
f09e2e
 	u_int status, id;
017ff1
@@ -876,7 +876,7 @@ do_symlink(struct sftp_conn *conn, char *oldpath, char *newpath)
017ff1
 }
017ff1
 
017ff1
 int
017ff1
-do_fsync(struct sftp_conn *conn, char *handle, u_int handle_len)
017ff1
+do_fsync(struct sftp_conn *conn, const char *handle, u_int handle_len)
017ff1
 {
017ff1
 	Buffer msg;
017ff1
 	u_int status, id;
017ff1
@@ -907,7 +907,7 @@ do_fsync(struct sftp_conn *conn, char *handle, u_int handle_len)
017ff1
 
017ff1
 #ifdef notyet
017ff1
 char *
017ff1
-do_readlink(struct sftp_conn *conn, char *path)
017ff1
+do_readlink(struct sftp_conn *conn, const char *path)
017ff1
 {
017ff1
 	Buffer msg;
017ff1
 	u_int type, expected_id, count, id;
017ff1
@@ -1010,7 +1010,7 @@ do_fstatvfs(struct sftp_conn *conn, const char *handle, u_int handle_len,
017ff1
 
017ff1
 static void
017ff1
 send_read_request(struct sftp_conn *conn, u_int id, u_int64_t offset,
017ff1
-    u_int len, char *handle, u_int handle_len)
017ff1
+    u_int len, const char *handle, u_int handle_len)
017ff1
 {
017ff1
 	Buffer msg;
017ff1
 
017ff1
@@ -1026,7 +1026,7 @@ send_read_request(struct sftp_conn *conn, u_int id, u_int64_t offset,
f09e2e
 }
f09e2e
 
f09e2e
 int
f09e2e
-do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
f09e2e
+do_download(struct sftp_conn *conn, const char *remote_path, const char *local_path,
017ff1
     Attrib *a, int preserve_flag, int resume_flag, int fsync_flag)
f09e2e
 {
f09e2e
 	Attrib junk;
017ff1
@@ -1308,7 +1308,7 @@ do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
f09e2e
 }
f09e2e
 
f09e2e
 static int
017ff1
-download_dir_internal(struct sftp_conn *conn, char *src, char *dst, int depth,
017ff1
+download_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, int depth,
017ff1
     Attrib *dirattrib, int preserve_flag, int print_flag, int resume_flag,
017ff1
     int fsync_flag)
f09e2e
 {
017ff1
@@ -1400,7 +1400,7 @@ download_dir_internal(struct sftp_conn *conn, char *src, char *dst, int depth,
f09e2e
 }
f09e2e
 
f09e2e
 int
f09e2e
-download_dir(struct sftp_conn *conn, char *src, char *dst,
f09e2e
+download_dir(struct sftp_conn *conn, const char *src, const char *dst,
017ff1
     Attrib *dirattrib, int preserve_flag, int print_flag,
017ff1
     int resume_flag, int fsync_flag)
f09e2e
 {
017ff1
@@ -1419,7 +1419,7 @@ download_dir(struct sftp_conn *conn, char *src, char *dst,
f09e2e
 }
f09e2e
 
f09e2e
 int
f09e2e
-do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
f09e2e
+do_upload(struct sftp_conn *conn, const char *local_path, const char *remote_path,
017ff1
     int preserve_flag, int fsync_flag)
f09e2e
 {
f09e2e
 	int local_fd;
017ff1
@@ -1607,7 +1607,7 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
f09e2e
 }
f09e2e
 
f09e2e
 static int
017ff1
-upload_dir_internal(struct sftp_conn *conn, char *src, char *dst, int depth,
017ff1
+upload_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, int depth,
017ff1
     int preserve_flag, int print_flag, int fsync_flag)
f09e2e
 {
f09e2e
 	int ret = 0, status;
017ff1
@@ -1700,7 +1700,7 @@ upload_dir_internal(struct sftp_conn *conn, char *src, char *dst, int depth,
f09e2e
 }
f09e2e
 
f09e2e
 int
017ff1
-upload_dir(struct sftp_conn *conn, char *src, char *dst, int preserve_flag,
017ff1
+upload_dir(struct sftp_conn *conn, const char *src, const char *dst, int preserve_flag,
017ff1
     int print_flag, int fsync_flag)
f09e2e
 {
f09e2e
 	char *dst_canon;
017ff1
@@ -1719,7 +1719,7 @@ upload_dir(struct sftp_conn *conn, char *src, char *dst, int preserve_flag,
f09e2e
 }
f09e2e
 
f09e2e
 char *
f09e2e
-path_append(char *p1, char *p2)
f09e2e
+path_append(const char *p1, const char *p2)
f09e2e
 {
f09e2e
 	char *ret;
f09e2e
 	size_t len = strlen(p1) + strlen(p2) + 2;
017ff1
diff --git a/sftp-client.h b/sftp-client.h
017ff1
index ba92ad0..c085423 100644
017ff1
--- a/sftp-client.h
017ff1
+++ b/sftp-client.h
017ff1
@@ -56,79 +56,79 @@ struct sftp_conn *do_init(int, int, u_int, u_int, u_int64_t);
f09e2e
 u_int sftp_proto_version(struct sftp_conn *);
f09e2e
 
f09e2e
 /* Close file referred to by 'handle' */
f09e2e
-int do_close(struct sftp_conn *, char *, u_int);
f09e2e
+int do_close(struct sftp_conn *, const char *, u_int);
f09e2e
 
f09e2e
 /* Read contents of 'path' to NULL-terminated array 'dir' */
f09e2e
-int do_readdir(struct sftp_conn *, char *, SFTP_DIRENT ***);
f09e2e
+int do_readdir(struct sftp_conn *, const char *, SFTP_DIRENT ***);
f09e2e
 
f09e2e
 /* Frees a NULL-terminated array of SFTP_DIRENTs (eg. from do_readdir) */
f09e2e
 void free_sftp_dirents(SFTP_DIRENT **);
f09e2e
 
f09e2e
 /* Delete file 'path' */
f09e2e
-int do_rm(struct sftp_conn *, char *);
f09e2e
+int do_rm(struct sftp_conn *, const char *);
f09e2e
 
f09e2e
 /* Create directory 'path' */
f09e2e
-int do_mkdir(struct sftp_conn *, char *, Attrib *, int);
f09e2e
+int do_mkdir(struct sftp_conn *, const char *, Attrib *, int);
f09e2e
 
f09e2e
 /* Remove directory 'path' */
f09e2e
-int do_rmdir(struct sftp_conn *, char *);
f09e2e
+int do_rmdir(struct sftp_conn *, const char *);
f09e2e
 
f09e2e
 /* Get file attributes of 'path' (follows symlinks) */
f09e2e
-Attrib *do_stat(struct sftp_conn *, char *, int);
f09e2e
+Attrib *do_stat(struct sftp_conn *, const char *, int);
f09e2e
 
f09e2e
 /* Get file attributes of 'path' (does not follow symlinks) */
f09e2e
-Attrib *do_lstat(struct sftp_conn *, char *, int);
f09e2e
+Attrib *do_lstat(struct sftp_conn *, const char *, int);
f09e2e
 
f09e2e
 /* Set file attributes of 'path' */
f09e2e
-int do_setstat(struct sftp_conn *, char *, Attrib *);
f09e2e
+int do_setstat(struct sftp_conn *, const char *, Attrib *);
f09e2e
 
f09e2e
 /* Set file attributes of open file 'handle' */
f09e2e
-int do_fsetstat(struct sftp_conn *, char *, u_int, Attrib *);
f09e2e
+int do_fsetstat(struct sftp_conn *, const char *, u_int, Attrib *);
f09e2e
 
f09e2e
 /* Canonicalise 'path' - caller must free result */
f09e2e
-char *do_realpath(struct sftp_conn *, char *);
f09e2e
+char *do_realpath(struct sftp_conn *, const char *);
f09e2e
 
f09e2e
 /* Get statistics for filesystem hosting file at "path" */
f09e2e
 int do_statvfs(struct sftp_conn *, const char *, struct sftp_statvfs *, int);
f09e2e
 
f09e2e
 /* Rename 'oldpath' to 'newpath' */
017ff1
-int do_rename(struct sftp_conn *, char *, char *m, int force_legacy);
017ff1
+int do_rename(struct sftp_conn *, const char *, const char *m, int force_legacy);
f09e2e
 
f09e2e
 /* Link 'oldpath' to 'newpath' */
f09e2e
-int do_hardlink(struct sftp_conn *, char *, char *);
f09e2e
+int do_hardlink(struct sftp_conn *, const char *, const char *);
f09e2e
 
017ff1
 /* Rename 'oldpath' to 'newpath' */
f09e2e
-int do_symlink(struct sftp_conn *, char *, char *);
f09e2e
+int do_symlink(struct sftp_conn *, const char *, const char *);
f09e2e
 
017ff1
 /* Call fsync() on open file 'handle' */
017ff1
-int do_fsync(struct sftp_conn *conn, char *, u_int);
017ff1
+int do_fsync(struct sftp_conn *conn, const char *, u_int);
f09e2e
 
017ff1
 /*
f09e2e
  * Download 'remote_path' to 'local_path'. Preserve permissions and times
f09e2e
  * if 'pflag' is set
f09e2e
  */
017ff1
-int do_download(struct sftp_conn *, char *, char *, Attrib *, int, int, int);
017ff1
+int do_download(struct sftp_conn *, const char *, const char *, Attrib *, int, int, int);
f09e2e
 
f09e2e
 /*
f09e2e
  * Recursively download 'remote_directory' to 'local_directory'. Preserve 
f09e2e
  * times if 'pflag' is set
f09e2e
  */
017ff1
-int download_dir(struct sftp_conn *, char *, char *, Attrib *, int,
017ff1
+int download_dir(struct sftp_conn *, const char *, const char *, Attrib *, int,
017ff1
     int, int, int);
f09e2e
 
f09e2e
 /*
f09e2e
  * Upload 'local_path' to 'remote_path'. Preserve permissions and times
f09e2e
  * if 'pflag' is set
f09e2e
  */
017ff1
-int do_upload(struct sftp_conn *, char *, char *, int, int);
017ff1
+int do_upload(struct sftp_conn *, const char *, const char *, int, int);
f09e2e
 
f09e2e
 /*
f09e2e
  * Recursively upload 'local_directory' to 'remote_directory'. Preserve 
f09e2e
  * times if 'pflag' is set
f09e2e
  */
017ff1
-int upload_dir(struct sftp_conn *, char *, char *, int, int, int);
017ff1
+int upload_dir(struct sftp_conn *, const char *, const char *, int, int, int);
f09e2e
 
f09e2e
 /* Concatenate paths, taking care of slashes. Caller must free result. */
f09e2e
-char *path_append(char *, char *);
f09e2e
+char *path_append(const char *, const char *);
f09e2e
 
f09e2e
 #endif
017ff1
diff --git a/sftp.c b/sftp.c
017ff1
index ad1f8c8..3987117 100644
017ff1
--- a/sftp.c
017ff1
+++ b/sftp.c
017ff1
@@ -218,7 +218,7 @@ killchild(int signo)
f09e2e
 {
f09e2e
 	if (sshpid > 1) {
f09e2e
 		kill(sshpid, SIGTERM);
f09e2e
-		waitpid(sshpid, NULL, 0);
f09e2e
+		(void) waitpid(sshpid, NULL, 0);
f09e2e
 	}
f09e2e
 
f09e2e
 	_exit(1);
017ff1
@@ -329,7 +329,7 @@ local_do_ls(const char *args)
f09e2e
 
f09e2e
 /* Strip one path (usually the pwd) from the start of another */
f09e2e
 static char *
f09e2e
-path_strip(char *path, char *strip)
f09e2e
+path_strip(const char *path, const char *strip)
f09e2e
 {
f09e2e
 	size_t len;
f09e2e
 
017ff1
@@ -347,7 +347,7 @@ path_strip(char *path, char *strip)
f09e2e
 }
f09e2e
 
f09e2e
 static char *
f09e2e
-make_absolute(char *p, char *pwd)
f09e2e
+make_absolute(char *p, const char *pwd)
f09e2e
 {
f09e2e
 	char *abs_str;
f09e2e
 
017ff1
@@ -545,7 +545,7 @@ parse_no_flags(const char *cmd, char **argv, int argc)
f09e2e
 }
f09e2e
 
f09e2e
 static int
f09e2e
-is_dir(char *path)
f09e2e
+is_dir(const char *path)
f09e2e
 {
f09e2e
 	struct stat sb;
f09e2e
 
017ff1
@@ -557,7 +557,7 @@ is_dir(char *path)
f09e2e
 }
f09e2e
 
f09e2e
 static int
f09e2e
-remote_is_dir(struct sftp_conn *conn, char *path)
f09e2e
+remote_is_dir(struct sftp_conn *conn, const char *path)
f09e2e
 {
f09e2e
 	Attrib *a;
f09e2e
 
017ff1
@@ -571,7 +571,7 @@ remote_is_dir(struct sftp_conn *conn, char *path)
f09e2e
 
f09e2e
 /* Check whether path returned from glob(..., GLOB_MARK, ...) is a directory */
f09e2e
 static int
f09e2e
-pathname_is_dir(char *pathname)
f09e2e
+pathname_is_dir(const char *pathname)
f09e2e
 {
f09e2e
 	size_t l = strlen(pathname);
f09e2e
 
017ff1
@@ -579,7 +579,7 @@ pathname_is_dir(char *pathname)
f09e2e
 }
f09e2e
 
f09e2e
 static int
f09e2e
-process_get(struct sftp_conn *conn, char *src, char *dst, char *pwd,
f09e2e
+process_get(struct sftp_conn *conn, const char *src, const char *dst, const char *pwd,
017ff1
     int pflag, int rflag, int resume, int fflag)
f09e2e
 {
f09e2e
 	char *abs_src = NULL;
017ff1
@@ -659,7 +659,7 @@ out:
f09e2e
 }
f09e2e
 
f09e2e
 static int
f09e2e
-process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd,
f09e2e
+process_put(struct sftp_conn *conn, const char *src, const char *dst, const char *pwd,
017ff1
     int pflag, int rflag, int fflag)
f09e2e
 {
f09e2e
 	char *tmp_dst = NULL;
017ff1
@@ -765,7 +765,7 @@ sdirent_comp(const void *aa, const void *bb)
f09e2e
 
f09e2e
 /* sftp ls.1 replacement for directories */
f09e2e
 static int
f09e2e
-do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
f09e2e
+do_ls_dir(struct sftp_conn *conn, const char *path, const char *strip_path, int lflag)
f09e2e
 {
f09e2e
 	int n;
f09e2e
 	u_int c = 1, colspace = 0, columns = 1;
017ff1
@@ -850,7 +850,7 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
f09e2e
 
f09e2e
 /* sftp ls.1 replacement which handles path globs */
f09e2e
 static int
f09e2e
-do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
f09e2e
+do_globbed_ls(struct sftp_conn *conn, const char *path, const char *strip_path,
f09e2e
     int lflag)
f09e2e
 {
f09e2e
 	char *fname, *lname;
017ff1
@@ -931,7 +931,7 @@ do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
f09e2e
 }
f09e2e
 
f09e2e
 static int
f09e2e
-do_df(struct sftp_conn *conn, char *path, int hflag, int iflag)
f09e2e
+do_df(struct sftp_conn *conn, const char *path, int hflag, int iflag)
f09e2e
 {
f09e2e
 	struct sftp_statvfs st;
f09e2e
 	char s_used[FMT_SCALED_STRSIZE];
017ff1
diff --git a/ssh-agent.c b/ssh-agent.c
017ff1
index 117fdde..2b50132 100644
017ff1
--- a/ssh-agent.c
017ff1
+++ b/ssh-agent.c
017ff1
@@ -1037,8 +1037,8 @@ main(int ac, char **av)
f09e2e
 	sanitise_stdfd();
f09e2e
 
f09e2e
 	/* drop */
f09e2e
-	setegid(getgid());
f09e2e
-	setgid(getgid());
f09e2e
+	(void) setegid(getgid());
f09e2e
+	(void) setgid(getgid());
f09e2e
 
f09e2e
 #if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
f09e2e
 	/* Disable ptrace on Linux without sgid bit */
017ff1
diff --git a/sshd.c b/sshd.c
017ff1
index 773bb02..1eaa9f7 100644
017ff1
--- a/sshd.c
017ff1
+++ b/sshd.c
017ff1
@@ -771,8 +771,10 @@ privsep_preauth(Authctxt *authctxt)
f09e2e
 		if (getuid() == 0 || geteuid() == 0)
f09e2e
 			privsep_preauth_child();
f09e2e
 		setproctitle("%s", "[net]");
f09e2e
-		if (box != NULL)
f09e2e
+		if (box != NULL) {
f09e2e
 			ssh_sandbox_child(box);
f09e2e
+			free(box);
f09e2e
+		}
f09e2e
 
f09e2e
 		return 0;
f09e2e
 	}
017ff1
@@ -1439,6 +1441,9 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s)
f09e2e
 		if (num_listen_socks < 0)
f09e2e
 			break;
f09e2e
 	}
f09e2e
+
f09e2e
+	if (fdset != NULL)
f09e2e
+		free(fdset);
f09e2e
 }
f09e2e
 
f09e2e