vishalmishra434 / rpms / openssh

Forked from rpms/openssh a month ago
Clone
Petr Lautrbach 44f0ac
diff --git a/auth-pam.c b/auth-pam.c
Petr Lautrbach 44f0ac
index cd1a775..690711e 100644
Petr Lautrbach 44f0ac
--- a/auth-pam.c
Petr Lautrbach 44f0ac
+++ b/auth-pam.c
Petr Lautrbach 44f0ac
@@ -216,7 +216,12 @@ pthread_join(sp_pthread_t thread, void **value)
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);
Jan F. Chadima c870e6
+	while (waitpid(thread, &status, 0) < 0) {                     
Jan F. Chadima c870e6
+		if (errno == EINTR)                                
Jan F. Chadima c870e6
+			continue;
Jan F. Chadima c870e6
+		fatal("%s: waitpid: %s", __func__,         
Jan F. Chadima c870e6
+				strerror(errno));                      
Jan F. Chadima c870e6
+	}
Jan F. Chadima 3b545b
 	return (status);
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 #endif
Petr Lautrbach 44f0ac
diff --git a/channels.c b/channels.c
Petr Lautrbach 44f0ac
index af3fdc2..39c9f89 100644
Petr Lautrbach 44f0ac
--- a/channels.c
Petr Lautrbach 44f0ac
+++ b/channels.c
Petr Lautrbach 44f0ac
@@ -233,11 +233,11 @@ channel_register_fds(Channel *c, int rfd, int wfd, int efd,
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;
Petr Lautrbach 44f0ac
@@ -255,11 +255,11 @@ channel_register_fds(Channel *c, int rfd, int wfd, int efd,
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
 }
Petr Lautrbach 44f0ac
diff --git a/clientloop.c b/clientloop.c
Petr Lautrbach 44f0ac
index 9c60108..d372b53 100644
Petr Lautrbach 44f0ac
--- a/clientloop.c
Petr Lautrbach 44f0ac
+++ b/clientloop.c
Petr Lautrbach 44f0ac
@@ -2081,14 +2081,15 @@ client_input_global_request(int type, u_int32_t seq, void *ctxt)
Petr Lautrbach 8a29de
 	char *rtype;
Petr Lautrbach 8a29de
 	int want_reply;
Petr Lautrbach 8a29de
 	int success = 0;
Petr Lautrbach 8a29de
+/* success is still 0 the packet is allways SSH2_MSG_REQUEST_FAILURE, isn't it? */
Petr Lautrbach 8a29de
 
Petr Lautrbach 8a29de
 	rtype = packet_get_string(NULL);
Petr Lautrbach 8a29de
 	want_reply = packet_get_char();
Petr Lautrbach 8a29de
 	debug("client_input_global_request: rtype %s want_reply %d",
Petr Lautrbach 8a29de
 	    rtype, want_reply);
Petr Lautrbach 8a29de
 	if (want_reply) {
Petr Lautrbach 8a29de
-		packet_start(success ?
Petr Lautrbach 8a29de
-		    SSH2_MSG_REQUEST_SUCCESS : SSH2_MSG_REQUEST_FAILURE);
Petr Lautrbach 8a29de
+		packet_start(/*success ?
Petr Lautrbach 8a29de
+		    SSH2_MSG_REQUEST_SUCCESS :*/ SSH2_MSG_REQUEST_FAILURE);
Petr Lautrbach 8a29de
 		packet_send();
Petr Lautrbach 8a29de
 		packet_write_wait();
Petr Lautrbach 8a29de
 	}
Petr Lautrbach 44f0ac
diff --git a/key.c b/key.c
Petr Lautrbach 44f0ac
index a2050f6..6487d81 100644
Petr Lautrbach 44f0ac
--- a/key.c
Petr Lautrbach 44f0ac
+++ b/key.c
Petr Lautrbach 44f0ac
@@ -880,8 +880,10 @@ key_read(Key *ret, char **cpp)
Jan F. Chadima 3b545b
 		success = 1;
Jan F. Chadima 3b545b
 /*XXXX*/
Jan F. Chadima 3b545b
 		key_free(k);
Jan F. Chadima 3b545b
+/*XXXX
Jan F. Chadima 3b545b
 		if (success != 1)
Jan F. Chadima 3b545b
 			break;
Jan F. Chadima 3b545b
+XXXX*/
Jan F. Chadima 3b545b
 		/* advance cp: skip whitespace and data */
Jan F. Chadima 3b545b
 		while (*cp == ' ' || *cp == '\t')
Jan F. Chadima 3b545b
 			cp++;
Petr Lautrbach 44f0ac
diff --git a/monitor.c b/monitor.c
Petr Lautrbach 44f0ac
index 3ff62b0..70b9b4c 100644
Petr Lautrbach 44f0ac
--- a/monitor.c
Petr Lautrbach 44f0ac
+++ b/monitor.c
Petr Lautrbach 44f0ac
@@ -472,7 +472,7 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
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);
Petr Lautrbach 44f0ac
@@ -1254,6 +1254,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
 
Petr Lautrbach 44f0ac
@@ -1275,9 +1279,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);
Petr Lautrbach 44f0ac
diff --git a/monitor_wrap.c b/monitor_wrap.c
Petr Lautrbach 44f0ac
index 6df236a..93f6535 100644
Petr Lautrbach 44f0ac
--- a/monitor_wrap.c
Petr Lautrbach 44f0ac
+++ b/monitor_wrap.c
Petr Lautrbach 44f0ac
@@ -743,10 +743,10 @@ mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen)
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);
Petr Lautrbach 44f0ac
diff --git a/openbsd-compat/bindresvport.c b/openbsd-compat/bindresvport.c
Petr Lautrbach 44f0ac
index c89f214..80115c2 100644
Petr Lautrbach 44f0ac
--- a/openbsd-compat/bindresvport.c
Petr Lautrbach 44f0ac
+++ b/openbsd-compat/bindresvport.c
Petr Lautrbach 44f0ac
@@ -58,7 +58,7 @@ bindresvport_sa(int sd, struct sockaddr *sa)
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) {
Petr Lautrbach 44f0ac
diff --git a/packet.c b/packet.c
Petr Lautrbach 44f0ac
index f5b122b..1305e87 100644
Petr Lautrbach 44f0ac
--- a/packet.c
Petr Lautrbach 44f0ac
+++ b/packet.c
Petr Lautrbach 44f0ac
@@ -1234,6 +1234,7 @@ packet_read_poll1(void)
Jan F. Chadima 3b545b
 		case DEATTACK_DETECTED:
Jan F. Chadima 3b545b
 			packet_disconnect("crc32 compensation attack: "
Jan F. Chadima 3b545b
 			    "network attack detected");
Jan F. Chadima 3b545b
+			break;
Jan F. Chadima 3b545b
 		case DEATTACK_DOS_DETECTED:
Jan F. Chadima 3b545b
 			packet_disconnect("deattack denial of "
Jan F. Chadima 3b545b
 			    "service detected");
Petr Lautrbach 44f0ac
diff --git a/progressmeter.c b/progressmeter.c
Petr Lautrbach 44f0ac
index bbbc706..ae6d1aa 100644
Petr Lautrbach 44f0ac
--- a/progressmeter.c
Petr Lautrbach 44f0ac
+++ b/progressmeter.c
Jan F. Chadima 3b545b
@@ -65,7 +65,7 @@ static void update_progress_meter(int);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 static time_t start;		/* start progress */
Jan F. Chadima 3b545b
 static time_t last_update;	/* last progress update */
Jan F. Chadima 3b545b
-static char *file;		/* name of the file being transferred */
Jan F. Chadima 3b545b
+static const char *file;	/* name of the file being transferred */
Petr Lautrbach 44f0ac
 static off_t start_pos;		/* initial position of transfer */
Jan F. Chadima 3b545b
 static off_t end_pos;		/* ending position of transfer */
Jan F. Chadima 3b545b
 static off_t cur_pos;		/* transfer position as of last refresh */
Petr Lautrbach 44f0ac
@@ -248,7 +248,7 @@ update_progress_meter(int ignore)
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 void
Jan F. Chadima 3b545b
-start_progress_meter(char *f, off_t filesize, off_t *ctr)
Jan F. Chadima 3b545b
+start_progress_meter(const char *f, off_t filesize, off_t *ctr)
Jan F. Chadima 3b545b
 {
Petr Lautrbach 84822b
 	start = last_update = monotime();
Jan F. Chadima 3b545b
 	file = f;
Petr Lautrbach 44f0ac
diff --git a/progressmeter.h b/progressmeter.h
Petr Lautrbach 44f0ac
index 10bab99..e9ca8f0 100644
Petr Lautrbach 44f0ac
--- a/progressmeter.h
Petr Lautrbach 44f0ac
+++ b/progressmeter.h
Jan F. Chadima 3b545b
@@ -23,5 +23,5 @@
Jan F. Chadima 3b545b
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Jan F. Chadima 3b545b
  */
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
-void	start_progress_meter(char *, off_t, off_t *);
Jan F. Chadima 3b545b
+void	start_progress_meter(const char *, off_t, off_t *);
Jan F. Chadima 3b545b
 void	stop_progress_meter(void);
Petr Lautrbach 44f0ac
diff --git a/scp.c b/scp.c
Petr Lautrbach 44f0ac
index 1178a07..d9bc016 100644
Petr Lautrbach 44f0ac
--- a/scp.c
Petr Lautrbach 44f0ac
+++ b/scp.c
Jan F. Chadima 3b545b
@@ -155,7 +155,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)
Petr Lautrbach 44f0ac
diff --git a/servconf.c b/servconf.c
Petr Lautrbach 44f0ac
index 3839928..d482e79 100644
Petr Lautrbach 44f0ac
--- a/servconf.c
Petr Lautrbach 44f0ac
+++ b/servconf.c
Petr Lautrbach 44f0ac
@@ -1382,7 +1382,7 @@ process_server_config_line(ServerOptions *options, char *line,
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++)
Petr Lautrbach 44f0ac
@@ -1473,8 +1473,9 @@ process_server_config_line(ServerOptions *options, char *line,
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
 
Petr Lautrbach 44f0ac
diff --git a/serverloop.c b/serverloop.c
Petr Lautrbach 44f0ac
index 2f8e3a0..e03bc6c 100644
Petr Lautrbach 44f0ac
--- a/serverloop.c
Petr Lautrbach 44f0ac
+++ b/serverloop.c
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
 
Petr Lautrbach 44f0ac
@@ -337,7 +337,7 @@ wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp,
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);
Petr Lautrbach 44f0ac
@@ -590,7 +590,7 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
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))
Petr Lautrbach 44f0ac
@@ -614,7 +614,7 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
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
 
Petr Lautrbach 44f0ac
@@ -644,7 +644,7 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
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
Petr Lautrbach 44f0ac
@@ -740,15 +740,15 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
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
 
Petr Lautrbach 44f0ac
@@ -947,7 +947,7 @@ server_input_window_size(int type, u_int32_t seq, void *ctxt)
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);
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Petr Lautrbach 44f0ac
@@ -1007,7 +1007,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;
Petr Lautrbach 44f0ac
diff --git a/sftp-client.c b/sftp-client.c
Petr Lautrbach 44f0ac
index 2f5907c..3a2affd 100644
Petr Lautrbach 44f0ac
--- a/sftp-client.c
Petr Lautrbach 44f0ac
+++ b/sftp-client.c
Petr Lautrbach 44f0ac
@@ -151,7 +151,7 @@ get_msg(struct sftp_conn *conn, Buffer *m)
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 static void
Jan F. Chadima 3b545b
-send_string_request(struct sftp_conn *conn, u_int id, u_int code, char *s,
Jan F. Chadima 3b545b
+send_string_request(struct sftp_conn *conn, u_int id, u_int code, const char *s,
Jan F. Chadima 3b545b
     u_int len)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	Buffer msg;
Petr Lautrbach 44f0ac
@@ -167,7 +167,7 @@ send_string_request(struct sftp_conn *conn, u_int id, u_int code, char *s,
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 static void
Jan F. Chadima 3b545b
 send_string_attrs_request(struct sftp_conn *conn, u_int id, u_int code,
Jan F. Chadima 3b545b
-    char *s, u_int len, Attrib *a)
Jan F. Chadima 3b545b
+    const char *s, u_int len, Attrib *a)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	Buffer msg;
Jan F. Chadima 3b545b
 
Petr Lautrbach 44f0ac
@@ -429,7 +429,7 @@ sftp_proto_version(struct sftp_conn *conn)
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 int
Jan F. Chadima 3b545b
-do_close(struct sftp_conn *conn, char *handle, u_int handle_len)
Jan F. Chadima 3b545b
+do_close(struct sftp_conn *conn, const char *handle, u_int handle_len)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	u_int id, status;
Jan F. Chadima 3b545b
 	Buffer msg;
Petr Lautrbach 44f0ac
@@ -454,7 +454,7 @@ do_close(struct sftp_conn *conn, char *handle, u_int handle_len)
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 static int
Petr Lautrbach 44f0ac
-do_lsreaddir(struct sftp_conn *conn, char *path, int print_flag,
Petr Lautrbach 44f0ac
+do_lsreaddir(struct sftp_conn *conn, const char *path, int print_flag,
Jan F. Chadima 3b545b
     SFTP_DIRENT ***dir)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	Buffer msg;
Petr Lautrbach 44f0ac
@@ -577,7 +577,7 @@ do_lsreaddir(struct sftp_conn *conn, char *path, int print_flag,
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 int
Jan F. Chadima 3b545b
-do_readdir(struct sftp_conn *conn, char *path, SFTP_DIRENT ***dir)
Jan F. Chadima 3b545b
+do_readdir(struct sftp_conn *conn, const char *path, SFTP_DIRENT ***dir)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	return(do_lsreaddir(conn, path, 0, dir));
Jan F. Chadima 3b545b
 }
Petr Lautrbach 44f0ac
@@ -597,7 +597,7 @@ void free_sftp_dirents(SFTP_DIRENT **s)
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 int
Jan F. Chadima 3b545b
-do_rm(struct sftp_conn *conn, char *path)
Jan F. Chadima 3b545b
+do_rm(struct sftp_conn *conn, const char *path)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	u_int status, id;
Jan F. Chadima 3b545b
 
Petr Lautrbach 44f0ac
@@ -612,7 +612,7 @@ do_rm(struct sftp_conn *conn, char *path)
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 int
Petr Lautrbach 44f0ac
-do_mkdir(struct sftp_conn *conn, char *path, Attrib *a, int print_flag)
Petr Lautrbach 44f0ac
+do_mkdir(struct sftp_conn *conn, const char *path, Attrib *a, int print_flag)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	u_int status, id;
Jan F. Chadima 3b545b
 
Petr Lautrbach 44f0ac
@@ -628,7 +628,7 @@ do_mkdir(struct sftp_conn *conn, char *path, Attrib *a, int print_flag)
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 int
Jan F. Chadima 3b545b
-do_rmdir(struct sftp_conn *conn, char *path)
Jan F. Chadima 3b545b
+do_rmdir(struct sftp_conn *conn, const char *path)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	u_int status, id;
Jan F. Chadima 3b545b
 
Petr Lautrbach 44f0ac
@@ -644,7 +644,7 @@ do_rmdir(struct sftp_conn *conn, char *path)
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 Attrib *
Jan F. Chadima 3b545b
-do_stat(struct sftp_conn *conn, char *path, int quiet)
Jan F. Chadima 3b545b
+do_stat(struct sftp_conn *conn, const char *path, int quiet)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	u_int id;
Jan F. Chadima 3b545b
 
Petr Lautrbach 44f0ac
@@ -658,7 +658,7 @@ do_stat(struct sftp_conn *conn, char *path, int quiet)
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 Attrib *
Jan F. Chadima 3b545b
-do_lstat(struct sftp_conn *conn, char *path, int quiet)
Jan F. Chadima 3b545b
+do_lstat(struct sftp_conn *conn, const char *path, int quiet)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	u_int id;
Jan F. Chadima 3b545b
 
Petr Lautrbach 44f0ac
@@ -679,7 +679,7 @@ do_lstat(struct sftp_conn *conn, char *path, int quiet)
Petr Lautrbach 44f0ac
 
Petr Lautrbach 44f0ac
 #ifdef notyet
Petr Lautrbach 44f0ac
 Attrib *
Petr Lautrbach 44f0ac
-do_fstat(struct sftp_conn *conn, char *handle, u_int handle_len, int quiet)
Petr Lautrbach 44f0ac
+do_fstat(struct sftp_conn *conn, const char *handle, u_int handle_len, int quiet)
Petr Lautrbach 44f0ac
 {
Petr Lautrbach 44f0ac
 	u_int id;
Petr Lautrbach 44f0ac
 
Petr Lautrbach 44f0ac
@@ -692,7 +692,7 @@ do_fstat(struct sftp_conn *conn, char *handle, u_int handle_len, int quiet)
Jan F. Chadima 3b545b
 #endif
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 int
Jan F. Chadima 3b545b
-do_setstat(struct sftp_conn *conn, char *path, Attrib *a)
Jan F. Chadima 3b545b
+do_setstat(struct sftp_conn *conn, const char *path, Attrib *a)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	u_int status, id;
Jan F. Chadima 3b545b
 
Petr Lautrbach 44f0ac
@@ -709,7 +709,7 @@ do_setstat(struct sftp_conn *conn, char *path, Attrib *a)
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 int
Jan F. Chadima 3b545b
-do_fsetstat(struct sftp_conn *conn, char *handle, u_int handle_len,
Jan F. Chadima 3b545b
+do_fsetstat(struct sftp_conn *conn, const char *handle, u_int handle_len,
Jan F. Chadima 3b545b
     Attrib *a)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	u_int status, id;
Petr Lautrbach 44f0ac
@@ -726,7 +726,7 @@ do_fsetstat(struct sftp_conn *conn, char *handle, u_int handle_len,
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 char *
Jan F. Chadima 3b545b
-do_realpath(struct sftp_conn *conn, char *path)
Jan F. Chadima 3b545b
+do_realpath(struct sftp_conn *conn, const char *path)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	Buffer msg;
Jan F. Chadima 3b545b
 	u_int type, expected_id, count, id;
Petr Lautrbach 44f0ac
@@ -775,7 +775,7 @@ do_realpath(struct sftp_conn *conn, char *path)
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 int
Petr Lautrbach 44f0ac
-do_rename(struct sftp_conn *conn, char *oldpath, char *newpath,
Petr Lautrbach 44f0ac
+do_rename(struct sftp_conn *conn, const char *oldpath, const char *newpath,
Petr Lautrbach 44f0ac
     int force_legacy)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	Buffer msg;
Petr Lautrbach 44f0ac
@@ -811,7 +811,7 @@ do_rename(struct sftp_conn *conn, char *oldpath, char *newpath,
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 int
Jan F. Chadima 3b545b
-do_hardlink(struct sftp_conn *conn, char *oldpath, char *newpath)
Jan F. Chadima 3b545b
+do_hardlink(struct sftp_conn *conn, const char *oldpath, const char *newpath)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	Buffer msg;
Jan F. Chadima 3b545b
 	u_int status, id;
Petr Lautrbach 44f0ac
@@ -844,7 +844,7 @@ do_hardlink(struct sftp_conn *conn, char *oldpath, char *newpath)
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 int
Jan F. Chadima 3b545b
-do_symlink(struct sftp_conn *conn, char *oldpath, char *newpath)
Jan F. Chadima 3b545b
+do_symlink(struct sftp_conn *conn, const char *oldpath, const char *newpath)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	Buffer msg;
Jan F. Chadima 3b545b
 	u_int status, id;
Petr Lautrbach 44f0ac
@@ -876,7 +876,7 @@ do_symlink(struct sftp_conn *conn, char *oldpath, char *newpath)
Petr Lautrbach 44f0ac
 }
Petr Lautrbach 44f0ac
 
Petr Lautrbach 44f0ac
 int
Petr Lautrbach 44f0ac
-do_fsync(struct sftp_conn *conn, char *handle, u_int handle_len)
Petr Lautrbach 44f0ac
+do_fsync(struct sftp_conn *conn, const char *handle, u_int handle_len)
Petr Lautrbach 44f0ac
 {
Petr Lautrbach 44f0ac
 	Buffer msg;
Petr Lautrbach 44f0ac
 	u_int status, id;
Petr Lautrbach 44f0ac
@@ -907,7 +907,7 @@ do_fsync(struct sftp_conn *conn, char *handle, u_int handle_len)
Petr Lautrbach 44f0ac
 
Petr Lautrbach 44f0ac
 #ifdef notyet
Petr Lautrbach 44f0ac
 char *
Petr Lautrbach 44f0ac
-do_readlink(struct sftp_conn *conn, char *path)
Petr Lautrbach 44f0ac
+do_readlink(struct sftp_conn *conn, const char *path)
Petr Lautrbach 44f0ac
 {
Petr Lautrbach 44f0ac
 	Buffer msg;
Petr Lautrbach 44f0ac
 	u_int type, expected_id, count, id;
Petr Lautrbach 44f0ac
@@ -1010,7 +1010,7 @@ do_fstatvfs(struct sftp_conn *conn, const char *handle, u_int handle_len,
Petr Lautrbach 44f0ac
 
Petr Lautrbach 44f0ac
 static void
Petr Lautrbach 44f0ac
 send_read_request(struct sftp_conn *conn, u_int id, u_int64_t offset,
Petr Lautrbach 44f0ac
-    u_int len, char *handle, u_int handle_len)
Petr Lautrbach 44f0ac
+    u_int len, const char *handle, u_int handle_len)
Petr Lautrbach 44f0ac
 {
Petr Lautrbach 44f0ac
 	Buffer msg;
Petr Lautrbach 44f0ac
 
Petr Lautrbach 44f0ac
@@ -1026,7 +1026,7 @@ send_read_request(struct sftp_conn *conn, u_int id, u_int64_t offset,
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 int
Jan F. Chadima 3b545b
-do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
Jan F. Chadima 3b545b
+do_download(struct sftp_conn *conn, const char *remote_path, const char *local_path,
Petr Lautrbach 44f0ac
     Attrib *a, int preserve_flag, int resume_flag, int fsync_flag)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	Attrib junk;
Petr Lautrbach 44f0ac
@@ -1308,7 +1308,7 @@ do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 static int
Petr Lautrbach 44f0ac
-download_dir_internal(struct sftp_conn *conn, char *src, char *dst, int depth,
Petr Lautrbach 44f0ac
+download_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, int depth,
Petr Lautrbach 44f0ac
     Attrib *dirattrib, int preserve_flag, int print_flag, int resume_flag,
Petr Lautrbach 44f0ac
     int fsync_flag)
Jan F. Chadima 3b545b
 {
Petr Lautrbach 44f0ac
@@ -1400,7 +1400,7 @@ download_dir_internal(struct sftp_conn *conn, char *src, char *dst, int depth,
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 int
Jan F. Chadima 3b545b
-download_dir(struct sftp_conn *conn, char *src, char *dst,
Jan F. Chadima 3b545b
+download_dir(struct sftp_conn *conn, const char *src, const char *dst,
Petr Lautrbach 44f0ac
     Attrib *dirattrib, int preserve_flag, int print_flag,
Petr Lautrbach 44f0ac
     int resume_flag, int fsync_flag)
Jan F. Chadima 3b545b
 {
Petr Lautrbach 44f0ac
@@ -1419,7 +1419,7 @@ download_dir(struct sftp_conn *conn, char *src, char *dst,
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 int
Jan F. Chadima 3b545b
-do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
Jan F. Chadima 3b545b
+do_upload(struct sftp_conn *conn, const char *local_path, const char *remote_path,
Petr Lautrbach 44f0ac
     int preserve_flag, int fsync_flag)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	int local_fd;
Petr Lautrbach 44f0ac
@@ -1607,7 +1607,7 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 static int
Petr Lautrbach 44f0ac
-upload_dir_internal(struct sftp_conn *conn, char *src, char *dst, int depth,
Petr Lautrbach 44f0ac
+upload_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, int depth,
Petr Lautrbach 44f0ac
     int preserve_flag, int print_flag, int fsync_flag)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	int ret = 0, status;
Petr Lautrbach 44f0ac
@@ -1700,7 +1700,7 @@ upload_dir_internal(struct sftp_conn *conn, char *src, char *dst, int depth,
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 int
Petr Lautrbach 44f0ac
-upload_dir(struct sftp_conn *conn, char *src, char *dst, int preserve_flag,
Petr Lautrbach 44f0ac
+upload_dir(struct sftp_conn *conn, const char *src, const char *dst, int preserve_flag,
Petr Lautrbach 44f0ac
     int print_flag, int fsync_flag)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	char *dst_canon;
Petr Lautrbach 44f0ac
@@ -1719,7 +1719,7 @@ upload_dir(struct sftp_conn *conn, char *src, char *dst, int preserve_flag,
Jan F. Chadima 3b545b
 }
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 char *
Jan F. Chadima 3b545b
-path_append(char *p1, char *p2)
Jan F. Chadima 3b545b
+path_append(const char *p1, const char *p2)
Jan F. Chadima 3b545b
 {
Jan F. Chadima 3b545b
 	char *ret;
Jan F. Chadima 3b545b
 	size_t len = strlen(p1) + strlen(p2) + 2;
Petr Lautrbach 44f0ac
diff --git a/sftp-client.h b/sftp-client.h
Petr Lautrbach 44f0ac
index ba92ad0..c085423 100644
Petr Lautrbach 44f0ac
--- a/sftp-client.h
Petr Lautrbach 44f0ac
+++ b/sftp-client.h
Petr Lautrbach 44f0ac
@@ -56,79 +56,79 @@ struct sftp_conn *do_init(int, int, u_int, u_int, u_int64_t);
Jan F. Chadima 3b545b
 u_int sftp_proto_version(struct sftp_conn *);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /* Close file referred to by 'handle' */
Jan F. Chadima 3b545b
-int do_close(struct sftp_conn *, char *, u_int);
Jan F. Chadima 3b545b
+int do_close(struct sftp_conn *, const char *, u_int);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /* Read contents of 'path' to NULL-terminated array 'dir' */
Jan F. Chadima 3b545b
-int do_readdir(struct sftp_conn *, char *, SFTP_DIRENT ***);
Jan F. Chadima 3b545b
+int do_readdir(struct sftp_conn *, const char *, SFTP_DIRENT ***);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /* Frees a NULL-terminated array of SFTP_DIRENTs (eg. from do_readdir) */
Jan F. Chadima 3b545b
 void free_sftp_dirents(SFTP_DIRENT **);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /* Delete file 'path' */
Jan F. Chadima 3b545b
-int do_rm(struct sftp_conn *, char *);
Jan F. Chadima 3b545b
+int do_rm(struct sftp_conn *, const char *);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /* Create directory 'path' */
Jan F. Chadima 3b545b
-int do_mkdir(struct sftp_conn *, char *, Attrib *, int);
Jan F. Chadima 3b545b
+int do_mkdir(struct sftp_conn *, const char *, Attrib *, int);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /* Remove directory 'path' */
Jan F. Chadima 3b545b
-int do_rmdir(struct sftp_conn *, char *);
Jan F. Chadima 3b545b
+int do_rmdir(struct sftp_conn *, const char *);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /* Get file attributes of 'path' (follows symlinks) */
Jan F. Chadima 3b545b
-Attrib *do_stat(struct sftp_conn *, char *, int);
Jan F. Chadima 3b545b
+Attrib *do_stat(struct sftp_conn *, const char *, int);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /* Get file attributes of 'path' (does not follow symlinks) */
Jan F. Chadima 3b545b
-Attrib *do_lstat(struct sftp_conn *, char *, int);
Jan F. Chadima 3b545b
+Attrib *do_lstat(struct sftp_conn *, const char *, int);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /* Set file attributes of 'path' */
Jan F. Chadima 3b545b
-int do_setstat(struct sftp_conn *, char *, Attrib *);
Jan F. Chadima 3b545b
+int do_setstat(struct sftp_conn *, const char *, Attrib *);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /* Set file attributes of open file 'handle' */
Jan F. Chadima 3b545b
-int do_fsetstat(struct sftp_conn *, char *, u_int, Attrib *);
Jan F. Chadima 3b545b
+int do_fsetstat(struct sftp_conn *, const char *, u_int, Attrib *);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /* Canonicalise 'path' - caller must free result */
Jan F. Chadima 3b545b
-char *do_realpath(struct sftp_conn *, char *);
Jan F. Chadima 3b545b
+char *do_realpath(struct sftp_conn *, const char *);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /* Get statistics for filesystem hosting file at "path" */
Jan F. Chadima 3b545b
 int do_statvfs(struct sftp_conn *, const char *, struct sftp_statvfs *, int);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /* Rename 'oldpath' to 'newpath' */
Petr Lautrbach 44f0ac
-int do_rename(struct sftp_conn *, char *, char *m, int force_legacy);
Petr Lautrbach 44f0ac
+int do_rename(struct sftp_conn *, const char *, const char *m, int force_legacy);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /* Link 'oldpath' to 'newpath' */
Jan F. Chadima 3b545b
-int do_hardlink(struct sftp_conn *, char *, char *);
Jan F. Chadima 3b545b
+int do_hardlink(struct sftp_conn *, const char *, const char *);
Jan F. Chadima 3b545b
 
Petr Lautrbach 44f0ac
 /* Rename 'oldpath' to 'newpath' */
Jan F. Chadima 3b545b
-int do_symlink(struct sftp_conn *, char *, char *);
Jan F. Chadima 3b545b
+int do_symlink(struct sftp_conn *, const char *, const char *);
Jan F. Chadima 3b545b
 
Petr Lautrbach 44f0ac
 /* Call fsync() on open file 'handle' */
Petr Lautrbach 44f0ac
-int do_fsync(struct sftp_conn *conn, char *, u_int);
Petr Lautrbach 44f0ac
+int do_fsync(struct sftp_conn *conn, const char *, u_int);
Jan F. Chadima 3b545b
 
Petr Lautrbach 44f0ac
 /*
Jan F. Chadima 3b545b
  * Download 'remote_path' to 'local_path'. Preserve permissions and times
Jan F. Chadima 3b545b
  * if 'pflag' is set
Jan F. Chadima 3b545b
  */
Petr Lautrbach 44f0ac
-int do_download(struct sftp_conn *, char *, char *, Attrib *, int, int, int);
Petr Lautrbach 44f0ac
+int do_download(struct sftp_conn *, const char *, const char *, Attrib *, int, int, int);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /*
Jan F. Chadima 3b545b
  * Recursively download 'remote_directory' to 'local_directory'. Preserve 
Jan F. Chadima 3b545b
  * times if 'pflag' is set
Jan F. Chadima 3b545b
  */
Petr Lautrbach 44f0ac
-int download_dir(struct sftp_conn *, char *, char *, Attrib *, int,
Petr Lautrbach 44f0ac
+int download_dir(struct sftp_conn *, const char *, const char *, Attrib *, int,
Petr Lautrbach 44f0ac
     int, int, int);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /*
Jan F. Chadima 3b545b
  * Upload 'local_path' to 'remote_path'. Preserve permissions and times
Jan F. Chadima 3b545b
  * if 'pflag' is set
Jan F. Chadima 3b545b
  */
Petr Lautrbach 44f0ac
-int do_upload(struct sftp_conn *, char *, char *, int, int);
Petr Lautrbach 44f0ac
+int do_upload(struct sftp_conn *, const char *, const char *, int, int);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /*
Jan F. Chadima 3b545b
  * Recursively upload 'local_directory' to 'remote_directory'. Preserve 
Jan F. Chadima 3b545b
  * times if 'pflag' is set
Jan F. Chadima 3b545b
  */
Petr Lautrbach 44f0ac
-int upload_dir(struct sftp_conn *, char *, char *, int, int, int);
Petr Lautrbach 44f0ac
+int upload_dir(struct sftp_conn *, const char *, const char *, int, int, int);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 /* Concatenate paths, taking care of slashes. Caller must free result. */
Jan F. Chadima 3b545b
-char *path_append(char *, char *);
Jan F. Chadima 3b545b
+char *path_append(const char *, const char *);
Jan F. Chadima 3b545b
 
Jan F. Chadima 3b545b
 #endif
Petr Lautrbach 44f0ac
diff --git a/sftp.c b/sftp.c
Petr Lautrbach 44f0ac
index ad1f8c8..3987117 100644
Petr Lautrbach 44f0ac
--- a/sftp.c
Petr Lautrbach 44f0ac
+++ b/sftp.c
Petr Lautrbach 44f0ac
@@ -218,7 +218,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);
Petr Lautrbach 44f0ac
@@ -329,7 +329,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
 
Petr Lautrbach 44f0ac
@@ -347,7 +347,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
 
Petr Lautrbach 44f0ac
@@ -545,7 +545,7 @@ parse_no_flags(const char *cmd, char **argv, int argc)
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
 
Petr Lautrbach 44f0ac
@@ -557,7 +557,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
 
Petr Lautrbach 44f0ac
@@ -571,7 +571,7 @@ remote_is_dir(struct sftp_conn *conn, char *path)
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
 
Petr Lautrbach 44f0ac
@@ -579,7 +579,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;
Petr Lautrbach 44f0ac
@@ -659,7 +659,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,
Petr Lautrbach 44f0ac
     int pflag, int rflag, int fflag)
Petr Lautrbach 84822b
 {
Petr Lautrbach 84822b
 	char *tmp_dst = NULL;
Petr Lautrbach 44f0ac
@@ -765,7 +765,7 @@ sdirent_comp(const void *aa, const void *bb)
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;
Petr Lautrbach 44f0ac
@@ -850,7 +850,7 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
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;
Petr Lautrbach 44f0ac
@@ -931,7 +931,7 @@ do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
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];
Petr Lautrbach 44f0ac
diff --git a/ssh-agent.c b/ssh-agent.c
Petr Lautrbach 44f0ac
index 117fdde..2b50132 100644
Petr Lautrbach 44f0ac
--- a/ssh-agent.c
Petr Lautrbach 44f0ac
+++ b/ssh-agent.c
Petr Lautrbach 44f0ac
@@ -1037,8 +1037,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 */
Petr Lautrbach 44f0ac
diff --git a/sshd.c b/sshd.c
Petr Lautrbach 44f0ac
index 773bb02..1eaa9f7 100644
Petr Lautrbach 44f0ac
--- a/sshd.c
Petr Lautrbach 44f0ac
+++ b/sshd.c
Petr Lautrbach 44f0ac
@@ -771,8 +771,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
 	}
Petr Lautrbach 44f0ac
@@ -1439,6 +1441,9 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s)
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