forked from rpms/openssh
936 lines
28 KiB
Diff
936 lines
28 KiB
Diff
diff --git a/auth-pam.c b/auth-pam.c
|
|
index cd1a775..2fff267 100644
|
|
--- a/auth-pam.c
|
|
+++ b/auth-pam.c
|
|
@@ -216,7 +216,12 @@ pthread_join(sp_pthread_t thread, void **value)
|
|
if (sshpam_thread_status != -1)
|
|
return (sshpam_thread_status);
|
|
signal(SIGCHLD, sshpam_oldsig);
|
|
- waitpid(thread, &status, 0);
|
|
+ while (waitpid(thread, &status, 0) < 0) {
|
|
+ if (errno == EINTR)
|
|
+ continue;
|
|
+ fatal("%s: waitpid: %s", __func__,
|
|
+ strerror(errno));
|
|
+ }
|
|
return (status);
|
|
}
|
|
#endif
|
|
diff --git a/channels.c b/channels.c
|
|
index 51a221d..0ef1d90 100644
|
|
--- a/channels.c
|
|
+++ b/channels.c
|
|
@@ -239,11 +239,11 @@ channel_register_fds(Channel *c, int rfd, int wfd, int efd,
|
|
channel_max_fd = MAX(channel_max_fd, wfd);
|
|
channel_max_fd = MAX(channel_max_fd, efd);
|
|
|
|
- if (rfd != -1)
|
|
+ if (rfd >= 0)
|
|
fcntl(rfd, F_SETFD, FD_CLOEXEC);
|
|
- if (wfd != -1 && wfd != rfd)
|
|
+ if (wfd >= 0 && wfd != rfd)
|
|
fcntl(wfd, F_SETFD, FD_CLOEXEC);
|
|
- if (efd != -1 && efd != rfd && efd != wfd)
|
|
+ if (efd >= 0 && efd != rfd && efd != wfd)
|
|
fcntl(efd, F_SETFD, FD_CLOEXEC);
|
|
|
|
c->rfd = rfd;
|
|
@@ -261,11 +261,11 @@ channel_register_fds(Channel *c, int rfd, int wfd, int efd,
|
|
|
|
/* enable nonblocking mode */
|
|
if (nonblock) {
|
|
- if (rfd != -1)
|
|
+ if (rfd >= 0)
|
|
set_nonblock(rfd);
|
|
- if (wfd != -1)
|
|
+ if (wfd >= 0)
|
|
set_nonblock(wfd);
|
|
- if (efd != -1)
|
|
+ if (efd >= 0)
|
|
set_nonblock(efd);
|
|
}
|
|
}
|
|
@@ -3959,13 +3959,13 @@ connect_local_xsocket_path(const char *pathname, int len)
|
|
int sock;
|
|
struct sockaddr_un addr;
|
|
|
|
+ if (len <= 0)
|
|
+ return -1;
|
|
sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
|
if (sock < 0)
|
|
error("socket: %.100s", strerror(errno));
|
|
memset(&addr, 0, sizeof(addr));
|
|
addr.sun_family = AF_UNIX;
|
|
- if (len <= 0)
|
|
- return -1;
|
|
if (len > sizeof addr.sun_path)
|
|
len = sizeof addr.sun_path;
|
|
memcpy(addr.sun_path, pathname, len);
|
|
diff --git a/clientloop.c b/clientloop.c
|
|
index 20ce0b5..65cb26a 100644
|
|
--- a/clientloop.c
|
|
+++ b/clientloop.c
|
|
@@ -2090,15 +2090,16 @@ client_input_global_request(int type, u_int32_t seq, void *ctxt)
|
|
{
|
|
char *rtype;
|
|
int want_reply;
|
|
- int success = 0;
|
|
+/* int success = 0;
|
|
+ success is still 0 the packet is allways SSH2_MSG_REQUEST_FAILURE, isn't it? */
|
|
|
|
rtype = packet_get_string(NULL);
|
|
want_reply = packet_get_char();
|
|
debug("client_input_global_request: rtype %s want_reply %d",
|
|
rtype, want_reply);
|
|
if (want_reply) {
|
|
- packet_start(success ?
|
|
- SSH2_MSG_REQUEST_SUCCESS : SSH2_MSG_REQUEST_FAILURE);
|
|
+ packet_start(/*success ?
|
|
+ SSH2_MSG_REQUEST_SUCCESS :*/ SSH2_MSG_REQUEST_FAILURE);
|
|
packet_send();
|
|
packet_write_wait();
|
|
}
|
|
diff --git a/entropy.c b/entropy.c
|
|
index 06b0095..a4097da 100644
|
|
--- a/entropy.c
|
|
+++ b/entropy.c
|
|
@@ -44,6 +44,7 @@
|
|
#include <openssl/err.h>
|
|
|
|
#include "openbsd-compat/openssl-compat.h"
|
|
+#include "openbsd-compat/port-linux.h"
|
|
|
|
#include "ssh.h"
|
|
#include "misc.h"
|
|
diff --git a/monitor.c b/monitor.c
|
|
index 07fa655..b8e6e06 100644
|
|
--- a/monitor.c
|
|
+++ b/monitor.c
|
|
@@ -488,7 +488,7 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
|
|
mm_get_keystate(pmonitor);
|
|
|
|
/* Drain any buffered messages from the child */
|
|
- while (pmonitor->m_log_recvfd != -1 && monitor_read_log(pmonitor) == 0)
|
|
+ while (pmonitor->m_log_recvfd >= 0 && monitor_read_log(pmonitor) == 0)
|
|
;
|
|
|
|
close(pmonitor->m_sendfd);
|
|
@@ -1276,6 +1276,10 @@ mm_answer_keyallowed(int sock, Buffer *m)
|
|
break;
|
|
}
|
|
}
|
|
+
|
|
+ debug3("%s: key %p is %s",
|
|
+ __func__, key, allowed ? "allowed" : "not allowed");
|
|
+
|
|
if (key != NULL)
|
|
key_free(key);
|
|
|
|
@@ -1297,9 +1301,6 @@ mm_answer_keyallowed(int sock, Buffer *m)
|
|
free(chost);
|
|
}
|
|
|
|
- debug3("%s: key %p is %s",
|
|
- __func__, key, allowed ? "allowed" : "not allowed");
|
|
-
|
|
buffer_clear(m);
|
|
buffer_put_int(m, allowed);
|
|
buffer_put_int(m, forced_command != NULL);
|
|
diff --git a/monitor_wrap.c b/monitor_wrap.c
|
|
index ba4ecd7..b3e4ca1 100644
|
|
--- a/monitor_wrap.c
|
|
+++ b/monitor_wrap.c
|
|
@@ -749,10 +749,10 @@ mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen)
|
|
if ((tmp1 = dup(pmonitor->m_recvfd)) == -1 ||
|
|
(tmp2 = dup(pmonitor->m_recvfd)) == -1) {
|
|
error("%s: cannot allocate fds for pty", __func__);
|
|
- if (tmp1 > 0)
|
|
+ if (tmp1 >= 0)
|
|
close(tmp1);
|
|
- if (tmp2 > 0)
|
|
- close(tmp2);
|
|
+ /*DEAD CODE if (tmp2 >= 0)
|
|
+ close(tmp2);*/
|
|
return 0;
|
|
}
|
|
close(tmp1);
|
|
diff --git a/openbsd-compat/bindresvport.c b/openbsd-compat/bindresvport.c
|
|
index c89f214..80115c2 100644
|
|
--- a/openbsd-compat/bindresvport.c
|
|
+++ b/openbsd-compat/bindresvport.c
|
|
@@ -58,7 +58,7 @@ bindresvport_sa(int sd, struct sockaddr *sa)
|
|
struct sockaddr_in6 *in6;
|
|
u_int16_t *portp;
|
|
u_int16_t port;
|
|
- socklen_t salen;
|
|
+ socklen_t salen = sizeof(struct sockaddr_storage);
|
|
int i;
|
|
|
|
if (sa == NULL) {
|
|
diff --git a/openbsd-compat/port-linux.h b/openbsd-compat/port-linux.h
|
|
index 8b7cda2..e2ca8a1 100644
|
|
--- a/openbsd-compat/port-linux.h
|
|
+++ b/openbsd-compat/port-linux.h
|
|
@@ -37,4 +37,6 @@ void oom_adjust_restore(void);
|
|
void oom_adjust_setup(void);
|
|
#endif
|
|
|
|
+void linux_seed(void);
|
|
+
|
|
#endif /* ! _PORT_LINUX_H */
|
|
diff --git a/packet.c b/packet.c
|
|
index 8ec353e..dbc2c33 100644
|
|
--- a/packet.c
|
|
+++ b/packet.c
|
|
@@ -1246,6 +1246,7 @@ packet_read_poll1(void)
|
|
case DEATTACK_DETECTED:
|
|
packet_disconnect("crc32 compensation attack: "
|
|
"network attack detected");
|
|
+ break;
|
|
case DEATTACK_DOS_DETECTED:
|
|
packet_disconnect("deattack denial of "
|
|
"service detected");
|
|
diff --git a/pam_ssh_agent_auth-0.9.3/pam_user_key_allowed2.c b/pam_ssh_agent_auth-0.9.3/pam_user_key_allowed2.c
|
|
index 8ba6d87..a7808c7 100644
|
|
--- a/pam_ssh_agent_auth-0.9.3/pam_user_key_allowed2.c
|
|
+++ b/pam_ssh_agent_auth-0.9.3/pam_user_key_allowed2.c
|
|
@@ -87,7 +87,7 @@ pam_user_key_allowed2(struct passwd *pw, Key *key, char *file)
|
|
found = key_new(key->type);
|
|
|
|
while (read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) {
|
|
- char *cp, *key_options = NULL;
|
|
+ char *cp = NULL;
|
|
|
|
/* Skip leading whitespace, empty and comment lines. */
|
|
for (cp = line; *cp == ' ' || *cp == '\t'; cp++)
|
|
@@ -99,7 +99,6 @@ pam_user_key_allowed2(struct passwd *pw, Key *key, char *file)
|
|
/* no key? check if there are options for this key */
|
|
int quoted = 0;
|
|
verbose("user_key_allowed: check options: '%s'", cp);
|
|
- key_options = cp;
|
|
for (; *cp && (quoted || (*cp != ' ' && *cp != '\t')); cp++) {
|
|
if (*cp == '\\' && cp[1] == '"')
|
|
cp++; /* Skip both */
|
|
diff --git a/pam_ssh_agent_auth-0.9.3/userauth_pubkey_from_id.c b/pam_ssh_agent_auth-0.9.3/userauth_pubkey_from_id.c
|
|
index e14eb27..323817a 100644
|
|
--- a/pam_ssh_agent_auth-0.9.3/userauth_pubkey_from_id.c
|
|
+++ b/pam_ssh_agent_auth-0.9.3/userauth_pubkey_from_id.c
|
|
@@ -89,8 +89,7 @@ userauth_pubkey_from_id(Identity * id)
|
|
authenticated = 1;
|
|
|
|
user_auth_clean_exit:
|
|
- if(&b != NULL)
|
|
- buffer_free(&b);
|
|
+ buffer_free(&b);
|
|
if(sig != NULL)
|
|
free(sig);
|
|
if(pkblob != NULL)
|
|
diff --git a/progressmeter.c b/progressmeter.c
|
|
index bbbc706..ae6d1aa 100644
|
|
--- a/progressmeter.c
|
|
+++ b/progressmeter.c
|
|
@@ -65,7 +65,7 @@ static void update_progress_meter(int);
|
|
|
|
static time_t start; /* start progress */
|
|
static time_t last_update; /* last progress update */
|
|
-static char *file; /* name of the file being transferred */
|
|
+static const char *file; /* name of the file being transferred */
|
|
static off_t start_pos; /* initial position of transfer */
|
|
static off_t end_pos; /* ending position of transfer */
|
|
static off_t cur_pos; /* transfer position as of last refresh */
|
|
@@ -248,7 +248,7 @@ update_progress_meter(int ignore)
|
|
}
|
|
|
|
void
|
|
-start_progress_meter(char *f, off_t filesize, off_t *ctr)
|
|
+start_progress_meter(const char *f, off_t filesize, off_t *ctr)
|
|
{
|
|
start = last_update = monotime();
|
|
file = f;
|
|
diff --git a/progressmeter.h b/progressmeter.h
|
|
index 10bab99..e9ca8f0 100644
|
|
--- a/progressmeter.h
|
|
+++ b/progressmeter.h
|
|
@@ -23,5 +23,5 @@
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*/
|
|
|
|
-void start_progress_meter(char *, off_t, off_t *);
|
|
+void start_progress_meter(const char *, off_t, off_t *);
|
|
void stop_progress_meter(void);
|
|
diff --git a/scp.c b/scp.c
|
|
index cbd904d..e4e9fa1 100644
|
|
--- a/scp.c
|
|
+++ b/scp.c
|
|
@@ -155,7 +155,7 @@ killchild(int signo)
|
|
{
|
|
if (do_cmd_pid > 1) {
|
|
kill(do_cmd_pid, signo ? signo : SIGTERM);
|
|
- waitpid(do_cmd_pid, NULL, 0);
|
|
+ (void) waitpid(do_cmd_pid, NULL, 0);
|
|
}
|
|
|
|
if (signo)
|
|
diff --git a/servconf.c b/servconf.c
|
|
index 87a311b..895cdca 100644
|
|
--- a/servconf.c
|
|
+++ b/servconf.c
|
|
@@ -1418,7 +1418,7 @@ process_server_config_line(ServerOptions *options, char *line,
|
|
fatal("%s line %d: Missing subsystem name.",
|
|
filename, linenum);
|
|
if (!*activep) {
|
|
- arg = strdelim(&cp);
|
|
+ /*arg =*/ (void) strdelim(&cp);
|
|
break;
|
|
}
|
|
for (i = 0; i < options->num_subsystems; i++)
|
|
@@ -1509,8 +1509,9 @@ process_server_config_line(ServerOptions *options, char *line,
|
|
if (*activep && *charptr == NULL) {
|
|
*charptr = tilde_expand_filename(arg, getuid());
|
|
/* increase optional counter */
|
|
- if (intptr != NULL)
|
|
- *intptr = *intptr + 1;
|
|
+ /* DEAD CODE intptr is still NULL ;)
|
|
+ if (intptr != NULL)
|
|
+ *intptr = *intptr + 1; */
|
|
}
|
|
break;
|
|
|
|
diff --git a/serverloop.c b/serverloop.c
|
|
index e92f9e2..3cad041 100644
|
|
--- a/serverloop.c
|
|
+++ b/serverloop.c
|
|
@@ -147,13 +147,13 @@ notify_setup(void)
|
|
static void
|
|
notify_parent(void)
|
|
{
|
|
- if (notify_pipe[1] != -1)
|
|
+ if (notify_pipe[1] >= 0)
|
|
(void)write(notify_pipe[1], "", 1);
|
|
}
|
|
static void
|
|
notify_prepare(fd_set *readset)
|
|
{
|
|
- if (notify_pipe[0] != -1)
|
|
+ if (notify_pipe[0] >= 0)
|
|
FD_SET(notify_pipe[0], readset);
|
|
}
|
|
static void
|
|
@@ -161,8 +161,8 @@ notify_done(fd_set *readset)
|
|
{
|
|
char c;
|
|
|
|
- if (notify_pipe[0] != -1 && FD_ISSET(notify_pipe[0], readset))
|
|
- while (read(notify_pipe[0], &c, 1) != -1)
|
|
+ if (notify_pipe[0] >= 0 && FD_ISSET(notify_pipe[0], readset))
|
|
+ while (read(notify_pipe[0], &c, 1) >= 0)
|
|
debug2("notify_done: reading");
|
|
}
|
|
|
|
@@ -337,7 +337,7 @@ wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp,
|
|
* If we have buffered data, try to write some of that data
|
|
* to the program.
|
|
*/
|
|
- if (fdin != -1 && buffer_len(&stdin_buffer) > 0)
|
|
+ if (fdin >= 0 && buffer_len(&stdin_buffer) > 0)
|
|
FD_SET(fdin, *writesetp);
|
|
}
|
|
notify_prepare(*readsetp);
|
|
@@ -477,7 +477,7 @@ process_output(fd_set *writeset)
|
|
int len;
|
|
|
|
/* Write buffered data to program stdin. */
|
|
- if (!compat20 && fdin != -1 && FD_ISSET(fdin, writeset)) {
|
|
+ if (!compat20 && fdin >= 0 && FD_ISSET(fdin, writeset)) {
|
|
data = buffer_ptr(&stdin_buffer);
|
|
dlen = buffer_len(&stdin_buffer);
|
|
len = write(fdin, data, dlen);
|
|
@@ -590,7 +590,7 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
|
|
set_nonblock(fdin);
|
|
set_nonblock(fdout);
|
|
/* we don't have stderr for interactive terminal sessions, see below */
|
|
- if (fderr != -1)
|
|
+ if (fderr >= 0)
|
|
set_nonblock(fderr);
|
|
|
|
if (!(datafellows & SSH_BUG_IGNOREMSG) && isatty(fdin))
|
|
@@ -614,7 +614,7 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
|
|
max_fd = MAX(connection_in, connection_out);
|
|
max_fd = MAX(max_fd, fdin);
|
|
max_fd = MAX(max_fd, fdout);
|
|
- if (fderr != -1)
|
|
+ if (fderr >= 0)
|
|
max_fd = MAX(max_fd, fderr);
|
|
#endif
|
|
|
|
@@ -644,7 +644,7 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
|
|
* If we have received eof, and there is no more pending
|
|
* input data, cause a real eof by closing fdin.
|
|
*/
|
|
- if (stdin_eof && fdin != -1 && buffer_len(&stdin_buffer) == 0) {
|
|
+ if (stdin_eof && fdin >= 0 && buffer_len(&stdin_buffer) == 0) {
|
|
if (fdin != fdout)
|
|
close(fdin);
|
|
else
|
|
@@ -740,15 +740,15 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
|
|
buffer_free(&stderr_buffer);
|
|
|
|
/* Close the file descriptors. */
|
|
- if (fdout != -1)
|
|
+ if (fdout >= 0)
|
|
close(fdout);
|
|
fdout = -1;
|
|
fdout_eof = 1;
|
|
- if (fderr != -1)
|
|
+ if (fderr >= 0)
|
|
close(fderr);
|
|
fderr = -1;
|
|
fderr_eof = 1;
|
|
- if (fdin != -1)
|
|
+ if (fdin >= 0)
|
|
close(fdin);
|
|
fdin = -1;
|
|
|
|
@@ -947,7 +947,7 @@ server_input_window_size(int type, u_int32_t seq, void *ctxt)
|
|
|
|
debug("Window change received.");
|
|
packet_check_eom();
|
|
- if (fdin != -1)
|
|
+ if (fdin >= 0)
|
|
pty_change_window_size(fdin, row, col, xpixel, ypixel);
|
|
}
|
|
|
|
@@ -1039,7 +1039,7 @@ server_request_tun(void)
|
|
}
|
|
|
|
tun = packet_get_int();
|
|
- if (forced_tun_device != -1) {
|
|
+ if (forced_tun_device >= 0) {
|
|
if (tun != SSH_TUNID_ANY && forced_tun_device != tun)
|
|
goto done;
|
|
tun = forced_tun_device;
|
|
diff --git a/sftp-client.c b/sftp-client.c
|
|
index 990b58d..3d0f22b 100644
|
|
--- a/sftp-client.c
|
|
+++ b/sftp-client.c
|
|
@@ -151,7 +151,7 @@ get_msg(struct sftp_conn *conn, Buffer *m)
|
|
}
|
|
|
|
static void
|
|
-send_string_request(struct sftp_conn *conn, u_int id, u_int code, char *s,
|
|
+send_string_request(struct sftp_conn *conn, u_int id, u_int code, const char *s,
|
|
u_int len)
|
|
{
|
|
Buffer msg;
|
|
@@ -167,7 +167,7 @@ send_string_request(struct sftp_conn *conn, u_int id, u_int code, char *s,
|
|
|
|
static void
|
|
send_string_attrs_request(struct sftp_conn *conn, u_int id, u_int code,
|
|
- char *s, u_int len, Attrib *a)
|
|
+ const char *s, u_int len, Attrib *a)
|
|
{
|
|
Buffer msg;
|
|
|
|
@@ -429,7 +429,7 @@ sftp_proto_version(struct sftp_conn *conn)
|
|
}
|
|
|
|
int
|
|
-do_close(struct sftp_conn *conn, char *handle, u_int handle_len)
|
|
+do_close(struct sftp_conn *conn, const char *handle, u_int handle_len)
|
|
{
|
|
u_int id, status;
|
|
Buffer msg;
|
|
@@ -454,7 +454,7 @@ do_close(struct sftp_conn *conn, char *handle, u_int handle_len)
|
|
|
|
|
|
static int
|
|
-do_lsreaddir(struct sftp_conn *conn, char *path, int print_flag,
|
|
+do_lsreaddir(struct sftp_conn *conn, const char *path, int print_flag,
|
|
SFTP_DIRENT ***dir)
|
|
{
|
|
Buffer msg;
|
|
@@ -577,7 +577,7 @@ do_lsreaddir(struct sftp_conn *conn, char *path, int print_flag,
|
|
}
|
|
|
|
int
|
|
-do_readdir(struct sftp_conn *conn, char *path, SFTP_DIRENT ***dir)
|
|
+do_readdir(struct sftp_conn *conn, const char *path, SFTP_DIRENT ***dir)
|
|
{
|
|
return(do_lsreaddir(conn, path, 0, dir));
|
|
}
|
|
@@ -597,7 +597,7 @@ void free_sftp_dirents(SFTP_DIRENT **s)
|
|
}
|
|
|
|
int
|
|
-do_rm(struct sftp_conn *conn, char *path)
|
|
+do_rm(struct sftp_conn *conn, const char *path)
|
|
{
|
|
u_int status, id;
|
|
|
|
@@ -612,7 +612,7 @@ do_rm(struct sftp_conn *conn, char *path)
|
|
}
|
|
|
|
int
|
|
-do_mkdir(struct sftp_conn *conn, char *path, Attrib *a, int print_flag)
|
|
+do_mkdir(struct sftp_conn *conn, const char *path, Attrib *a, int print_flag)
|
|
{
|
|
u_int status, id;
|
|
|
|
@@ -628,7 +628,7 @@ do_mkdir(struct sftp_conn *conn, char *path, Attrib *a, int print_flag)
|
|
}
|
|
|
|
int
|
|
-do_rmdir(struct sftp_conn *conn, char *path)
|
|
+do_rmdir(struct sftp_conn *conn, const char *path)
|
|
{
|
|
u_int status, id;
|
|
|
|
@@ -644,7 +644,7 @@ do_rmdir(struct sftp_conn *conn, char *path)
|
|
}
|
|
|
|
Attrib *
|
|
-do_stat(struct sftp_conn *conn, char *path, int quiet)
|
|
+do_stat(struct sftp_conn *conn, const char *path, int quiet)
|
|
{
|
|
u_int id;
|
|
|
|
@@ -658,7 +658,7 @@ do_stat(struct sftp_conn *conn, char *path, int quiet)
|
|
}
|
|
|
|
Attrib *
|
|
-do_lstat(struct sftp_conn *conn, char *path, int quiet)
|
|
+do_lstat(struct sftp_conn *conn, const char *path, int quiet)
|
|
{
|
|
u_int id;
|
|
|
|
@@ -679,7 +679,7 @@ do_lstat(struct sftp_conn *conn, char *path, int quiet)
|
|
|
|
#ifdef notyet
|
|
Attrib *
|
|
-do_fstat(struct sftp_conn *conn, char *handle, u_int handle_len, int quiet)
|
|
+do_fstat(struct sftp_conn *conn, const char *handle, u_int handle_len, int quiet)
|
|
{
|
|
u_int id;
|
|
|
|
@@ -692,7 +692,7 @@ do_fstat(struct sftp_conn *conn, char *handle, u_int handle_len, int quiet)
|
|
#endif
|
|
|
|
int
|
|
-do_setstat(struct sftp_conn *conn, char *path, Attrib *a)
|
|
+do_setstat(struct sftp_conn *conn, const char *path, Attrib *a)
|
|
{
|
|
u_int status, id;
|
|
|
|
@@ -709,7 +709,7 @@ do_setstat(struct sftp_conn *conn, char *path, Attrib *a)
|
|
}
|
|
|
|
int
|
|
-do_fsetstat(struct sftp_conn *conn, char *handle, u_int handle_len,
|
|
+do_fsetstat(struct sftp_conn *conn, const char *handle, u_int handle_len,
|
|
Attrib *a)
|
|
{
|
|
u_int status, id;
|
|
@@ -726,7 +726,7 @@ do_fsetstat(struct sftp_conn *conn, char *handle, u_int handle_len,
|
|
}
|
|
|
|
char *
|
|
-do_realpath(struct sftp_conn *conn, char *path)
|
|
+do_realpath(struct sftp_conn *conn, const char *path)
|
|
{
|
|
Buffer msg;
|
|
u_int type, expected_id, count, id;
|
|
@@ -775,7 +775,7 @@ do_realpath(struct sftp_conn *conn, char *path)
|
|
}
|
|
|
|
int
|
|
-do_rename(struct sftp_conn *conn, char *oldpath, char *newpath,
|
|
+do_rename(struct sftp_conn *conn, const char *oldpath, const char *newpath,
|
|
int force_legacy)
|
|
{
|
|
Buffer msg;
|
|
@@ -811,7 +811,7 @@ do_rename(struct sftp_conn *conn, char *oldpath, char *newpath,
|
|
}
|
|
|
|
int
|
|
-do_hardlink(struct sftp_conn *conn, char *oldpath, char *newpath)
|
|
+do_hardlink(struct sftp_conn *conn, const char *oldpath, const char *newpath)
|
|
{
|
|
Buffer msg;
|
|
u_int status, id;
|
|
@@ -844,7 +844,7 @@ do_hardlink(struct sftp_conn *conn, char *oldpath, char *newpath)
|
|
}
|
|
|
|
int
|
|
-do_symlink(struct sftp_conn *conn, char *oldpath, char *newpath)
|
|
+do_symlink(struct sftp_conn *conn, const char *oldpath, const char *newpath)
|
|
{
|
|
Buffer msg;
|
|
u_int status, id;
|
|
@@ -876,7 +876,7 @@ do_symlink(struct sftp_conn *conn, char *oldpath, char *newpath)
|
|
}
|
|
|
|
int
|
|
-do_fsync(struct sftp_conn *conn, char *handle, u_int handle_len)
|
|
+do_fsync(struct sftp_conn *conn, const char *handle, u_int handle_len)
|
|
{
|
|
Buffer msg;
|
|
u_int status, id;
|
|
@@ -907,7 +907,7 @@ do_fsync(struct sftp_conn *conn, char *handle, u_int handle_len)
|
|
|
|
#ifdef notyet
|
|
char *
|
|
-do_readlink(struct sftp_conn *conn, char *path)
|
|
+do_readlink(struct sftp_conn *conn, const char *path)
|
|
{
|
|
Buffer msg;
|
|
u_int type, expected_id, count, id;
|
|
@@ -1010,7 +1010,7 @@ do_fstatvfs(struct sftp_conn *conn, const char *handle, u_int handle_len,
|
|
|
|
static void
|
|
send_read_request(struct sftp_conn *conn, u_int id, u_int64_t offset,
|
|
- u_int len, char *handle, u_int handle_len)
|
|
+ u_int len, const char *handle, u_int handle_len)
|
|
{
|
|
Buffer msg;
|
|
|
|
@@ -1026,7 +1026,7 @@ send_read_request(struct sftp_conn *conn, u_int id, u_int64_t offset,
|
|
}
|
|
|
|
int
|
|
-do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
|
|
+do_download(struct sftp_conn *conn, const char *remote_path, const char *local_path,
|
|
Attrib *a, int preserve_flag, int resume_flag, int fsync_flag)
|
|
{
|
|
Attrib junk;
|
|
@@ -1308,7 +1308,7 @@ do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
|
|
}
|
|
|
|
static int
|
|
-download_dir_internal(struct sftp_conn *conn, char *src, char *dst, int depth,
|
|
+download_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, int depth,
|
|
Attrib *dirattrib, int preserve_flag, int print_flag, int resume_flag,
|
|
int fsync_flag)
|
|
{
|
|
@@ -1400,7 +1400,7 @@ download_dir_internal(struct sftp_conn *conn, char *src, char *dst, int depth,
|
|
}
|
|
|
|
int
|
|
-download_dir(struct sftp_conn *conn, char *src, char *dst,
|
|
+download_dir(struct sftp_conn *conn, const char *src, const char *dst,
|
|
Attrib *dirattrib, int preserve_flag, int print_flag,
|
|
int resume_flag, int fsync_flag)
|
|
{
|
|
@@ -1419,7 +1419,7 @@ download_dir(struct sftp_conn *conn, char *src, char *dst,
|
|
}
|
|
|
|
int
|
|
-do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
|
|
+do_upload(struct sftp_conn *conn, const char *local_path, const char *remote_path,
|
|
int preserve_flag, int resume, int fsync_flag)
|
|
{
|
|
int local_fd;
|
|
@@ -1628,7 +1628,7 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
|
|
}
|
|
|
|
static int
|
|
-upload_dir_internal(struct sftp_conn *conn, char *src, char *dst, int depth,
|
|
+upload_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, int depth,
|
|
int preserve_flag, int print_flag, int resume, int fsync_flag)
|
|
{
|
|
int ret = 0, status;
|
|
@@ -1721,7 +1721,7 @@ upload_dir_internal(struct sftp_conn *conn, char *src, char *dst, int depth,
|
|
}
|
|
|
|
int
|
|
-upload_dir(struct sftp_conn *conn, char *src, char *dst, int preserve_flag,
|
|
+upload_dir(struct sftp_conn *conn, const char *src, const char *dst, int preserve_flag,
|
|
int print_flag, int resume, int fsync_flag)
|
|
{
|
|
char *dst_canon;
|
|
@@ -1740,7 +1740,7 @@ upload_dir(struct sftp_conn *conn, char *src, char *dst, int preserve_flag,
|
|
}
|
|
|
|
char *
|
|
-path_append(char *p1, char *p2)
|
|
+path_append(const char *p1, const char *p2)
|
|
{
|
|
char *ret;
|
|
size_t len = strlen(p1) + strlen(p2) + 2;
|
|
diff --git a/sftp-client.h b/sftp-client.h
|
|
index 967840b..ffbcade 100644
|
|
--- a/sftp-client.h
|
|
+++ b/sftp-client.h
|
|
@@ -56,79 +56,79 @@ struct sftp_conn *do_init(int, int, u_int, u_int, u_int64_t);
|
|
u_int sftp_proto_version(struct sftp_conn *);
|
|
|
|
/* Close file referred to by 'handle' */
|
|
-int do_close(struct sftp_conn *, char *, u_int);
|
|
+int do_close(struct sftp_conn *, const char *, u_int);
|
|
|
|
/* Read contents of 'path' to NULL-terminated array 'dir' */
|
|
-int do_readdir(struct sftp_conn *, char *, SFTP_DIRENT ***);
|
|
+int do_readdir(struct sftp_conn *, const char *, SFTP_DIRENT ***);
|
|
|
|
/* Frees a NULL-terminated array of SFTP_DIRENTs (eg. from do_readdir) */
|
|
void free_sftp_dirents(SFTP_DIRENT **);
|
|
|
|
/* Delete file 'path' */
|
|
-int do_rm(struct sftp_conn *, char *);
|
|
+int do_rm(struct sftp_conn *, const char *);
|
|
|
|
/* Create directory 'path' */
|
|
-int do_mkdir(struct sftp_conn *, char *, Attrib *, int);
|
|
+int do_mkdir(struct sftp_conn *, const char *, Attrib *, int);
|
|
|
|
/* Remove directory 'path' */
|
|
-int do_rmdir(struct sftp_conn *, char *);
|
|
+int do_rmdir(struct sftp_conn *, const char *);
|
|
|
|
/* Get file attributes of 'path' (follows symlinks) */
|
|
-Attrib *do_stat(struct sftp_conn *, char *, int);
|
|
+Attrib *do_stat(struct sftp_conn *, const char *, int);
|
|
|
|
/* Get file attributes of 'path' (does not follow symlinks) */
|
|
-Attrib *do_lstat(struct sftp_conn *, char *, int);
|
|
+Attrib *do_lstat(struct sftp_conn *, const char *, int);
|
|
|
|
/* Set file attributes of 'path' */
|
|
-int do_setstat(struct sftp_conn *, char *, Attrib *);
|
|
+int do_setstat(struct sftp_conn *, const char *, Attrib *);
|
|
|
|
/* Set file attributes of open file 'handle' */
|
|
-int do_fsetstat(struct sftp_conn *, char *, u_int, Attrib *);
|
|
+int do_fsetstat(struct sftp_conn *, const char *, u_int, Attrib *);
|
|
|
|
/* Canonicalise 'path' - caller must free result */
|
|
-char *do_realpath(struct sftp_conn *, char *);
|
|
+char *do_realpath(struct sftp_conn *, const char *);
|
|
|
|
/* Get statistics for filesystem hosting file at "path" */
|
|
int do_statvfs(struct sftp_conn *, const char *, struct sftp_statvfs *, int);
|
|
|
|
/* Rename 'oldpath' to 'newpath' */
|
|
-int do_rename(struct sftp_conn *, char *, char *m, int force_legacy);
|
|
+int do_rename(struct sftp_conn *, const char *, const char *m, int force_legacy);
|
|
|
|
/* Link 'oldpath' to 'newpath' */
|
|
-int do_hardlink(struct sftp_conn *, char *, char *);
|
|
+int do_hardlink(struct sftp_conn *, const char *, const char *);
|
|
|
|
/* Rename 'oldpath' to 'newpath' */
|
|
-int do_symlink(struct sftp_conn *, char *, char *);
|
|
+int do_symlink(struct sftp_conn *, const char *, const char *);
|
|
|
|
/* Call fsync() on open file 'handle' */
|
|
-int do_fsync(struct sftp_conn *conn, char *, u_int);
|
|
+int do_fsync(struct sftp_conn *conn, const char *, u_int);
|
|
|
|
/*
|
|
* Download 'remote_path' to 'local_path'. Preserve permissions and times
|
|
* if 'pflag' is set
|
|
*/
|
|
-int do_download(struct sftp_conn *, char *, char *, Attrib *, int, int, int);
|
|
+int do_download(struct sftp_conn *, const char *, const char *, Attrib *, int, int, int);
|
|
|
|
/*
|
|
* Recursively download 'remote_directory' to 'local_directory'. Preserve
|
|
* times if 'pflag' is set
|
|
*/
|
|
-int download_dir(struct sftp_conn *, char *, char *, Attrib *, int,
|
|
+int download_dir(struct sftp_conn *, const char *, const char *, Attrib *, int,
|
|
int, int, int);
|
|
|
|
/*
|
|
* Upload 'local_path' to 'remote_path'. Preserve permissions and times
|
|
* if 'pflag' is set
|
|
*/
|
|
-int do_upload(struct sftp_conn *, char *, char *, int, int, int);
|
|
+int do_upload(struct sftp_conn *, const char *, const char *, int, int, int);
|
|
|
|
/*
|
|
* Recursively upload 'local_directory' to 'remote_directory'. Preserve
|
|
* times if 'pflag' is set
|
|
*/
|
|
-int upload_dir(struct sftp_conn *, char *, char *, int, int, int, int);
|
|
+int upload_dir(struct sftp_conn *, const char *, const char *, int, int, int, int);
|
|
|
|
/* Concatenate paths, taking care of slashes. Caller must free result. */
|
|
-char *path_append(char *, char *);
|
|
+char *path_append(const char *, const char *);
|
|
|
|
#endif
|
|
diff --git a/sftp.c b/sftp.c
|
|
index ff4d63d..4439100 100644
|
|
--- a/sftp.c
|
|
+++ b/sftp.c
|
|
@@ -220,7 +220,7 @@ killchild(int signo)
|
|
{
|
|
if (sshpid > 1) {
|
|
kill(sshpid, SIGTERM);
|
|
- waitpid(sshpid, NULL, 0);
|
|
+ (void) waitpid(sshpid, NULL, 0);
|
|
}
|
|
|
|
_exit(1);
|
|
@@ -332,7 +332,7 @@ local_do_ls(const char *args)
|
|
|
|
/* Strip one path (usually the pwd) from the start of another */
|
|
static char *
|
|
-path_strip(char *path, char *strip)
|
|
+path_strip(const char *path, const char *strip)
|
|
{
|
|
size_t len;
|
|
|
|
@@ -350,7 +350,7 @@ path_strip(char *path, char *strip)
|
|
}
|
|
|
|
static char *
|
|
-make_absolute(char *p, char *pwd)
|
|
+make_absolute(char *p, const char *pwd)
|
|
{
|
|
char *abs_str;
|
|
|
|
@@ -548,7 +548,7 @@ parse_no_flags(const char *cmd, char **argv, int argc)
|
|
}
|
|
|
|
static int
|
|
-is_dir(char *path)
|
|
+is_dir(const char *path)
|
|
{
|
|
struct stat sb;
|
|
|
|
@@ -560,7 +560,7 @@ is_dir(char *path)
|
|
}
|
|
|
|
static int
|
|
-remote_is_dir(struct sftp_conn *conn, char *path)
|
|
+remote_is_dir(struct sftp_conn *conn, const char *path)
|
|
{
|
|
Attrib *a;
|
|
|
|
@@ -574,7 +574,7 @@ remote_is_dir(struct sftp_conn *conn, char *path)
|
|
|
|
/* Check whether path returned from glob(..., GLOB_MARK, ...) is a directory */
|
|
static int
|
|
-pathname_is_dir(char *pathname)
|
|
+pathname_is_dir(const char *pathname)
|
|
{
|
|
size_t l = strlen(pathname);
|
|
|
|
@@ -582,7 +582,7 @@ pathname_is_dir(char *pathname)
|
|
}
|
|
|
|
static int
|
|
-process_get(struct sftp_conn *conn, char *src, char *dst, char *pwd,
|
|
+process_get(struct sftp_conn *conn, const char *src, const char *dst, const char *pwd,
|
|
int pflag, int rflag, int resume, int fflag)
|
|
{
|
|
char *abs_src = NULL;
|
|
@@ -666,7 +666,7 @@ out:
|
|
}
|
|
|
|
static int
|
|
-process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd,
|
|
+process_put(struct sftp_conn *conn, const char *src, const char *dst, const char *pwd,
|
|
int pflag, int rflag, int resume, int fflag)
|
|
{
|
|
char *tmp_dst = NULL;
|
|
@@ -776,7 +776,7 @@ sdirent_comp(const void *aa, const void *bb)
|
|
|
|
/* sftp ls.1 replacement for directories */
|
|
static int
|
|
-do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
|
|
+do_ls_dir(struct sftp_conn *conn, const char *path, const char *strip_path, int lflag)
|
|
{
|
|
int n;
|
|
u_int c = 1, colspace = 0, columns = 1;
|
|
@@ -861,7 +861,7 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
|
|
|
|
/* sftp ls.1 replacement which handles path globs */
|
|
static int
|
|
-do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
|
|
+do_globbed_ls(struct sftp_conn *conn, const char *path, const char *strip_path,
|
|
int lflag)
|
|
{
|
|
char *fname, *lname;
|
|
@@ -946,7 +946,7 @@ do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
|
|
}
|
|
|
|
static int
|
|
-do_df(struct sftp_conn *conn, char *path, int hflag, int iflag)
|
|
+do_df(struct sftp_conn *conn, const char *path, int hflag, int iflag)
|
|
{
|
|
struct sftp_statvfs st;
|
|
char s_used[FMT_SCALED_STRSIZE];
|
|
diff --git a/ssh-agent.c b/ssh-agent.c
|
|
index c8036c8..4da3bb6 100644
|
|
--- a/ssh-agent.c
|
|
+++ b/ssh-agent.c
|
|
@@ -1056,8 +1056,8 @@ main(int ac, char **av)
|
|
sanitise_stdfd();
|
|
|
|
/* drop */
|
|
- setegid(getgid());
|
|
- setgid(getgid());
|
|
+ (void) setegid(getgid());
|
|
+ (void) setgid(getgid());
|
|
|
|
#if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
|
|
/* Disable ptrace on Linux without sgid bit */
|
|
diff --git a/ssh-keygen.c b/ssh-keygen.c
|
|
index 64fa217..635e8fd 100644
|
|
--- a/ssh-keygen.c
|
|
+++ b/ssh-keygen.c
|
|
@@ -687,11 +687,11 @@ do_convert_from(struct passwd *pw)
|
|
fatal("%s: unknown key format %d", __func__, convert_format);
|
|
}
|
|
|
|
- if (!private)
|
|
+ if (!private) {
|
|
ok = key_write(k, stdout);
|
|
if (ok)
|
|
fprintf(stdout, "\n");
|
|
- else {
|
|
+ } else {
|
|
switch (k->type) {
|
|
case KEY_DSA:
|
|
ok = PEM_write_DSAPrivateKey(stdout, k->dsa, NULL,
|
|
diff --git a/sshd.c b/sshd.c
|
|
index 783abe3..eaade2a 100644
|
|
--- a/sshd.c
|
|
+++ b/sshd.c
|
|
@@ -771,8 +771,10 @@ privsep_preauth(Authctxt *authctxt)
|
|
if (getuid() == 0 || geteuid() == 0)
|
|
privsep_preauth_child();
|
|
setproctitle("%s", "[net]");
|
|
- if (box != NULL)
|
|
+ if (box != NULL) {
|
|
ssh_sandbox_child(box);
|
|
+ free(box);
|
|
+ }
|
|
|
|
return 0;
|
|
}
|
|
@@ -1458,6 +1460,9 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s)
|
|
if (num_listen_socks < 0)
|
|
break;
|
|
}
|
|
+
|
|
+ if (fdset != NULL)
|
|
+ free(fdset);
|
|
}
|
|
|
|
|
|
diff --git a/sshkey.c b/sshkey.c
|
|
index 5e3d97f..dae8270 100644
|
|
--- a/sshkey.c
|
|
+++ b/sshkey.c
|
|
@@ -54,6 +54,7 @@
|
|
#include "digest.h"
|
|
#define SSHKEY_INTERNAL
|
|
#include "sshkey.h"
|
|
+#include "log.h"
|
|
|
|
/* openssh private key file format */
|
|
#define MARK_BEGIN "-----BEGIN OPENSSH PRIVATE KEY-----\n"
|