From 44f0ac8d085ecbed384b08385022514512f5f7be Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Thu, 13 Nov 2014 16:43:15 +0100 Subject: [PATCH] fix several coverity issues Resolves: rhbz#1139794 --- ...ty.patch => openssh-6.6.1p1-coverity.patch | 360 ++++++++++-------- openssh.spec | 4 +- 2 files changed, 210 insertions(+), 154 deletions(-) rename openssh-6.3p1-coverity.patch => openssh-6.6.1p1-coverity.patch (65%) diff --git a/openssh-6.3p1-coverity.patch b/openssh-6.6.1p1-coverity.patch similarity index 65% rename from openssh-6.3p1-coverity.patch rename to openssh-6.6.1p1-coverity.patch index 69bcb81..9f71f9c 100644 --- a/openssh-6.3p1-coverity.patch +++ b/openssh-6.6.1p1-coverity.patch @@ -1,7 +1,8 @@ -diff -up openssh-6.3p1/auth-pam.c.coverity openssh-6.3p1/auth-pam.c ---- openssh-6.3p1/auth-pam.c.coverity 2013-06-02 00:07:32.000000000 +0200 -+++ openssh-6.3p1/auth-pam.c 2013-10-07 13:20:36.288298063 +0200 -@@ -216,7 +216,12 @@ pthread_join(sp_pthread_t thread, void * +diff --git a/auth-pam.c b/auth-pam.c +index cd1a775..690711e 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); @@ -15,10 +16,11 @@ diff -up openssh-6.3p1/auth-pam.c.coverity openssh-6.3p1/auth-pam.c return (status); } #endif -diff -up openssh-6.3p1/channels.c.coverity openssh-6.3p1/channels.c ---- openssh-6.3p1/channels.c.coverity 2013-09-13 08:19:31.000000000 +0200 -+++ openssh-6.3p1/channels.c 2013-10-07 13:20:36.289298058 +0200 -@@ -233,11 +233,11 @@ channel_register_fds(Channel *c, int rfd +diff --git a/channels.c b/channels.c +index af3fdc2..39c9f89 100644 +--- a/channels.c ++++ b/channels.c +@@ -233,11 +233,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); @@ -33,7 +35,7 @@ diff -up openssh-6.3p1/channels.c.coverity openssh-6.3p1/channels.c fcntl(efd, F_SETFD, FD_CLOEXEC); c->rfd = rfd; -@@ -255,11 +255,11 @@ channel_register_fds(Channel *c, int rfd +@@ -255,11 +255,11 @@ channel_register_fds(Channel *c, int rfd, int wfd, int efd, /* enable nonblocking mode */ if (nonblock) { @@ -48,10 +50,11 @@ diff -up openssh-6.3p1/channels.c.coverity openssh-6.3p1/channels.c set_nonblock(efd); } } -diff -up openssh-6.3p1/clientloop.c.coverity openssh-6.3p1/clientloop.c ---- openssh-6.3p1/clientloop.c.coverity 2013-06-10 05:07:12.000000000 +0200 -+++ openssh-6.3p1/clientloop.c 2013-10-07 13:20:36.289298058 +0200 -@@ -2068,14 +2068,15 @@ client_input_global_request(int type, u_ +diff --git a/clientloop.c b/clientloop.c +index 9c60108..d372b53 100644 +--- a/clientloop.c ++++ b/clientloop.c +@@ -2081,14 +2081,15 @@ client_input_global_request(int type, u_int32_t seq, void *ctxt) char *rtype; int want_reply; int success = 0; @@ -69,10 +72,11 @@ diff -up openssh-6.3p1/clientloop.c.coverity openssh-6.3p1/clientloop.c packet_send(); packet_write_wait(); } -diff -up openssh-6.3p1/key.c.coverity openssh-6.3p1/key.c ---- openssh-6.3p1/key.c.coverity 2013-06-01 23:41:51.000000000 +0200 -+++ openssh-6.3p1/key.c 2013-10-07 13:20:36.290298054 +0200 -@@ -807,8 +807,10 @@ key_read(Key *ret, char **cpp) +diff --git a/key.c b/key.c +index a2050f6..6487d81 100644 +--- a/key.c ++++ b/key.c +@@ -880,8 +880,10 @@ key_read(Key *ret, char **cpp) success = 1; /*XXXX*/ key_free(k); @@ -83,10 +87,11 @@ diff -up openssh-6.3p1/key.c.coverity openssh-6.3p1/key.c /* advance cp: skip whitespace and data */ while (*cp == ' ' || *cp == '\t') cp++; -diff -up openssh-6.3p1/monitor.c.coverity openssh-6.3p1/monitor.c ---- openssh-6.3p1/monitor.c.coverity 2013-07-20 05:21:53.000000000 +0200 -+++ openssh-6.3p1/monitor.c 2013-10-07 13:54:36.761314042 +0200 -@@ -449,7 +449,7 @@ monitor_child_preauth(Authctxt *_authctx +diff --git a/monitor.c b/monitor.c +index 3ff62b0..70b9b4c 100644 +--- a/monitor.c ++++ b/monitor.c +@@ -472,7 +472,7 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor) mm_get_keystate(pmonitor); /* Drain any buffered messages from the child */ @@ -95,7 +100,7 @@ diff -up openssh-6.3p1/monitor.c.coverity openssh-6.3p1/monitor.c ; close(pmonitor->m_sendfd); -@@ -1202,6 +1202,10 @@ mm_answer_keyallowed(int sock, Buffer *m +@@ -1254,6 +1254,10 @@ mm_answer_keyallowed(int sock, Buffer *m) break; } } @@ -106,7 +111,7 @@ diff -up openssh-6.3p1/monitor.c.coverity openssh-6.3p1/monitor.c if (key != NULL) key_free(key); -@@ -1223,9 +1227,6 @@ mm_answer_keyallowed(int sock, Buffer *m +@@ -1275,9 +1279,6 @@ mm_answer_keyallowed(int sock, Buffer *m) free(chost); } @@ -116,10 +121,11 @@ diff -up openssh-6.3p1/monitor.c.coverity openssh-6.3p1/monitor.c buffer_clear(m); buffer_put_int(m, allowed); buffer_put_int(m, forced_command != NULL); -diff -up openssh-6.3p1/monitor_wrap.c.coverity openssh-6.3p1/monitor_wrap.c ---- openssh-6.3p1/monitor_wrap.c.coverity 2013-06-02 00:07:32.000000000 +0200 -+++ openssh-6.3p1/monitor_wrap.c 2013-10-07 13:20:36.291298049 +0200 -@@ -710,10 +710,10 @@ mm_pty_allocate(int *ptyfd, int *ttyfd, +diff --git a/monitor_wrap.c b/monitor_wrap.c +index 6df236a..93f6535 100644 +--- a/monitor_wrap.c ++++ b/monitor_wrap.c +@@ -743,10 +743,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__); @@ -133,10 +139,11 @@ diff -up openssh-6.3p1/monitor_wrap.c.coverity openssh-6.3p1/monitor_wrap.c return 0; } close(tmp1); -diff -up openssh-6.3p1/openbsd-compat/bindresvport.c.coverity openssh-6.3p1/openbsd-compat/bindresvport.c ---- openssh-6.3p1/openbsd-compat/bindresvport.c.coverity 2010-12-03 00:50:26.000000000 +0100 -+++ openssh-6.3p1/openbsd-compat/bindresvport.c 2013-10-07 13:20:36.291298049 +0200 -@@ -58,7 +58,7 @@ bindresvport_sa(int sd, struct sockaddr +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; @@ -145,10 +152,11 @@ diff -up openssh-6.3p1/openbsd-compat/bindresvport.c.coverity openssh-6.3p1/open int i; if (sa == NULL) { -diff -up openssh-6.3p1/packet.c.coverity openssh-6.3p1/packet.c ---- openssh-6.3p1/packet.c.coverity 2013-07-18 08:12:45.000000000 +0200 -+++ openssh-6.3p1/packet.c 2013-10-07 13:20:36.291298049 +0200 -@@ -1199,6 +1199,7 @@ packet_read_poll1(void) +diff --git a/packet.c b/packet.c +index f5b122b..1305e87 100644 +--- a/packet.c ++++ b/packet.c +@@ -1234,6 +1234,7 @@ packet_read_poll1(void) case DEATTACK_DETECTED: packet_disconnect("crc32 compensation attack: " "network attack detected"); @@ -156,19 +164,20 @@ diff -up openssh-6.3p1/packet.c.coverity openssh-6.3p1/packet.c case DEATTACK_DOS_DETECTED: packet_disconnect("deattack denial of " "service detected"); -diff -up openssh-6.3p1/progressmeter.c.coverity openssh-6.3p1/progressmeter.c ---- openssh-6.3p1/progressmeter.c.coverity 2013-06-02 15:46:24.000000000 +0200 -+++ openssh-6.3p1/progressmeter.c 2013-10-07 13:42:32.377850691 +0200 +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 */ - static volatile off_t *counter; /* progress counter */ -@@ -247,7 +247,7 @@ update_progress_meter(int ignore) +@@ -248,7 +248,7 @@ update_progress_meter(int ignore) } void @@ -177,9 +186,10 @@ diff -up openssh-6.3p1/progressmeter.c.coverity openssh-6.3p1/progressmeter.c { start = last_update = monotime(); file = f; -diff -up openssh-6.3p1/progressmeter.h.coverity openssh-6.3p1/progressmeter.h ---- openssh-6.3p1/progressmeter.h.coverity 2006-03-26 05:30:02.000000000 +0200 -+++ openssh-6.3p1/progressmeter.h 2013-10-07 13:20:36.292298044 +0200 +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. */ @@ -187,9 +197,10 @@ diff -up openssh-6.3p1/progressmeter.h.coverity openssh-6.3p1/progressmeter.h -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 -up openssh-6.3p1/scp.c.coverity openssh-6.3p1/scp.c ---- openssh-6.3p1/scp.c.coverity 2013-07-18 08:11:25.000000000 +0200 -+++ openssh-6.3p1/scp.c 2013-10-07 13:20:36.292298044 +0200 +diff --git a/scp.c b/scp.c +index 1178a07..d9bc016 100644 +--- a/scp.c ++++ b/scp.c @@ -155,7 +155,7 @@ killchild(int signo) { if (do_cmd_pid > 1) { @@ -199,10 +210,11 @@ diff -up openssh-6.3p1/scp.c.coverity openssh-6.3p1/scp.c } if (signo) -diff -up openssh-6.3p1/servconf.c.coverity openssh-6.3p1/servconf.c ---- openssh-6.3p1/servconf.c.coverity 2013-07-20 05:21:53.000000000 +0200 -+++ openssh-6.3p1/servconf.c 2013-10-07 13:20:36.293298039 +0200 -@@ -1323,7 +1323,7 @@ process_server_config_line(ServerOptions +diff --git a/servconf.c b/servconf.c +index 3839928..d482e79 100644 +--- a/servconf.c ++++ b/servconf.c +@@ -1382,7 +1382,7 @@ process_server_config_line(ServerOptions *options, char *line, fatal("%s line %d: Missing subsystem name.", filename, linenum); if (!*activep) { @@ -211,7 +223,7 @@ diff -up openssh-6.3p1/servconf.c.coverity openssh-6.3p1/servconf.c break; } for (i = 0; i < options->num_subsystems; i++) -@@ -1414,8 +1414,9 @@ process_server_config_line(ServerOptions +@@ -1473,8 +1473,9 @@ process_server_config_line(ServerOptions *options, char *line, if (*activep && *charptr == NULL) { *charptr = tilde_expand_filename(arg, getuid()); /* increase optional counter */ @@ -223,9 +235,10 @@ diff -up openssh-6.3p1/servconf.c.coverity openssh-6.3p1/servconf.c } break; -diff -up openssh-6.3p1/serverloop.c.coverity openssh-6.3p1/serverloop.c ---- openssh-6.3p1/serverloop.c.coverity 2013-07-18 08:12:45.000000000 +0200 -+++ openssh-6.3p1/serverloop.c 2013-10-07 13:43:36.620537138 +0200 +diff --git a/serverloop.c b/serverloop.c +index 2f8e3a0..e03bc6c 100644 +--- a/serverloop.c ++++ b/serverloop.c @@ -147,13 +147,13 @@ notify_setup(void) static void notify_parent(void) @@ -253,7 +266,7 @@ diff -up openssh-6.3p1/serverloop.c.coverity openssh-6.3p1/serverloop.c debug2("notify_done: reading"); } -@@ -336,7 +336,7 @@ wait_until_can_do_something(fd_set **rea +@@ -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. */ @@ -262,7 +275,7 @@ diff -up openssh-6.3p1/serverloop.c.coverity openssh-6.3p1/serverloop.c FD_SET(fdin, *writesetp); } notify_prepare(*readsetp); -@@ -476,7 +476,7 @@ process_output(fd_set *writeset) +@@ -477,7 +477,7 @@ process_output(fd_set *writeset) int len; /* Write buffered data to program stdin. */ @@ -271,7 +284,7 @@ diff -up openssh-6.3p1/serverloop.c.coverity openssh-6.3p1/serverloop.c data = buffer_ptr(&stdin_buffer); dlen = buffer_len(&stdin_buffer); len = write(fdin, data, dlen); -@@ -589,7 +589,7 @@ server_loop(pid_t pid, int fdin_arg, int +@@ -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 */ @@ -280,7 +293,7 @@ diff -up openssh-6.3p1/serverloop.c.coverity openssh-6.3p1/serverloop.c set_nonblock(fderr); if (!(datafellows & SSH_BUG_IGNOREMSG) && isatty(fdin)) -@@ -613,7 +613,7 @@ server_loop(pid_t pid, int fdin_arg, int +@@ -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); @@ -289,7 +302,7 @@ diff -up openssh-6.3p1/serverloop.c.coverity openssh-6.3p1/serverloop.c max_fd = MAX(max_fd, fderr); #endif -@@ -643,7 +643,7 @@ server_loop(pid_t pid, int fdin_arg, int +@@ -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. */ @@ -298,7 +311,7 @@ diff -up openssh-6.3p1/serverloop.c.coverity openssh-6.3p1/serverloop.c if (fdin != fdout) close(fdin); else -@@ -739,15 +739,15 @@ server_loop(pid_t pid, int fdin_arg, int +@@ -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. */ @@ -317,7 +330,7 @@ diff -up openssh-6.3p1/serverloop.c.coverity openssh-6.3p1/serverloop.c close(fdin); fdin = -1; -@@ -946,7 +946,7 @@ server_input_window_size(int type, u_int +@@ -947,7 +947,7 @@ server_input_window_size(int type, u_int32_t seq, void *ctxt) debug("Window change received."); packet_check_eom(); @@ -326,7 +339,7 @@ diff -up openssh-6.3p1/serverloop.c.coverity openssh-6.3p1/serverloop.c pty_change_window_size(fdin, row, col, xpixel, ypixel); } -@@ -1006,7 +1006,7 @@ server_request_tun(void) +@@ -1007,7 +1007,7 @@ server_request_tun(void) } tun = packet_get_int(); @@ -335,10 +348,11 @@ diff -up openssh-6.3p1/serverloop.c.coverity openssh-6.3p1/serverloop.c if (tun != SSH_TUNID_ANY && forced_tun_device != tun) goto done; tun = forced_tun_device; -diff -up openssh-6.3p1/sftp-client.c.coverity openssh-6.3p1/sftp-client.c ---- openssh-6.3p1/sftp-client.c.coverity 2013-07-26 00:40:00.000000000 +0200 -+++ openssh-6.3p1/sftp-client.c 2013-10-07 13:48:45.885027420 +0200 -@@ -149,7 +149,7 @@ get_msg(struct sftp_conn *conn, Buffer * +diff --git a/sftp-client.c b/sftp-client.c +index 2f5907c..3a2affd 100644 +--- a/sftp-client.c ++++ b/sftp-client.c +@@ -151,7 +151,7 @@ get_msg(struct sftp_conn *conn, Buffer *m) } static void @@ -347,7 +361,7 @@ diff -up openssh-6.3p1/sftp-client.c.coverity openssh-6.3p1/sftp-client.c u_int len) { Buffer msg; -@@ -165,7 +165,7 @@ send_string_request(struct sftp_conn *co +@@ -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, @@ -356,7 +370,7 @@ diff -up openssh-6.3p1/sftp-client.c.coverity openssh-6.3p1/sftp-client.c { Buffer msg; -@@ -422,7 +422,7 @@ sftp_proto_version(struct sftp_conn *con +@@ -429,7 +429,7 @@ sftp_proto_version(struct sftp_conn *conn) } int @@ -365,16 +379,16 @@ diff -up openssh-6.3p1/sftp-client.c.coverity openssh-6.3p1/sftp-client.c { u_int id, status; Buffer msg; -@@ -447,7 +447,7 @@ do_close(struct sftp_conn *conn, char *h +@@ -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 printflag, -+do_lsreaddir(struct sftp_conn *conn, const char *path, int printflag, +-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; -@@ -572,7 +572,7 @@ do_lsreaddir(struct sftp_conn *conn, cha +@@ -577,7 +577,7 @@ do_lsreaddir(struct sftp_conn *conn, char *path, int print_flag, } int @@ -383,7 +397,7 @@ diff -up openssh-6.3p1/sftp-client.c.coverity openssh-6.3p1/sftp-client.c { return(do_lsreaddir(conn, path, 0, dir)); } -@@ -590,7 +590,7 @@ void free_sftp_dirents(SFTP_DIRENT **s) +@@ -597,7 +597,7 @@ void free_sftp_dirents(SFTP_DIRENT **s) } int @@ -392,16 +406,16 @@ diff -up openssh-6.3p1/sftp-client.c.coverity openssh-6.3p1/sftp-client.c { u_int status, id; -@@ -605,7 +605,7 @@ do_rm(struct sftp_conn *conn, char *path +@@ -612,7 +612,7 @@ do_rm(struct sftp_conn *conn, char *path) } int --do_mkdir(struct sftp_conn *conn, char *path, Attrib *a, int printflag) -+do_mkdir(struct sftp_conn *conn, const char *path, Attrib *a, int printflag) +-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; -@@ -621,7 +621,7 @@ do_mkdir(struct sftp_conn *conn, char *p +@@ -628,7 +628,7 @@ do_mkdir(struct sftp_conn *conn, char *path, Attrib *a, int print_flag) } int @@ -410,7 +424,7 @@ diff -up openssh-6.3p1/sftp-client.c.coverity openssh-6.3p1/sftp-client.c { u_int status, id; -@@ -637,7 +637,7 @@ do_rmdir(struct sftp_conn *conn, char *p +@@ -644,7 +644,7 @@ do_rmdir(struct sftp_conn *conn, char *path) } Attrib * @@ -419,7 +433,7 @@ diff -up openssh-6.3p1/sftp-client.c.coverity openssh-6.3p1/sftp-client.c { u_int id; -@@ -651,7 +651,7 @@ do_stat(struct sftp_conn *conn, char *pa +@@ -658,7 +658,7 @@ do_stat(struct sftp_conn *conn, char *path, int quiet) } Attrib * @@ -428,7 +442,16 @@ diff -up openssh-6.3p1/sftp-client.c.coverity openssh-6.3p1/sftp-client.c { u_int id; -@@ -685,7 +685,7 @@ do_fstat(struct sftp_conn *conn, char *h +@@ -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 @@ -437,7 +460,7 @@ diff -up openssh-6.3p1/sftp-client.c.coverity openssh-6.3p1/sftp-client.c { u_int status, id; -@@ -702,7 +702,7 @@ do_setstat(struct sftp_conn *conn, char +@@ -709,7 +709,7 @@ do_setstat(struct sftp_conn *conn, char *path, Attrib *a) } int @@ -446,7 +469,7 @@ diff -up openssh-6.3p1/sftp-client.c.coverity openssh-6.3p1/sftp-client.c Attrib *a) { u_int status, id; -@@ -719,7 +719,7 @@ do_fsetstat(struct sftp_conn *conn, char +@@ -726,7 +726,7 @@ do_fsetstat(struct sftp_conn *conn, char *handle, u_int handle_len, } char * @@ -455,16 +478,16 @@ diff -up openssh-6.3p1/sftp-client.c.coverity openssh-6.3p1/sftp-client.c { Buffer msg; u_int type, expected_id, count, id; -@@ -768,7 +768,7 @@ do_realpath(struct sftp_conn *conn, char +@@ -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) +-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; - u_int status, id; -@@ -802,7 +802,7 @@ do_rename(struct sftp_conn *conn, char * +@@ -811,7 +811,7 @@ do_rename(struct sftp_conn *conn, char *oldpath, char *newpath, } int @@ -473,7 +496,7 @@ diff -up openssh-6.3p1/sftp-client.c.coverity openssh-6.3p1/sftp-client.c { Buffer msg; u_int status, id; -@@ -835,7 +835,7 @@ do_hardlink(struct sftp_conn *conn, char +@@ -844,7 +844,7 @@ do_hardlink(struct sftp_conn *conn, char *oldpath, char *newpath) } int @@ -482,61 +505,88 @@ diff -up openssh-6.3p1/sftp-client.c.coverity openssh-6.3p1/sftp-client.c { Buffer msg; u_int status, id; -@@ -987,7 +987,7 @@ send_read_request(struct sftp_conn *conn +@@ -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 pflag, int resume) + Attrib *a, int preserve_flag, int resume_flag, int fsync_flag) { Attrib junk; -@@ -1255,7 +1255,7 @@ do_download(struct sftp_conn *conn, char +@@ -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, -+download_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, - Attrib *dirattrib, int pflag, int printflag, int depth, int resume) +-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) { - int i, ret = 0; -@@ -1345,7 +1345,7 @@ download_dir_internal(struct sftp_conn * +@@ -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 pflag, int printflag, int resume) + Attrib *dirattrib, int preserve_flag, int print_flag, + int resume_flag, int fsync_flag) { - char *src_canon; -@@ -1363,7 +1363,7 @@ download_dir(struct sftp_conn *conn, cha +@@ -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 pflag) + int preserve_flag, int fsync_flag) { int local_fd; -@@ -1548,7 +1548,7 @@ do_upload(struct sftp_conn *conn, char * +@@ -1607,7 +1607,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, -+upload_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, - int pflag, int printflag, int depth) +-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 fsync_flag) { int ret = 0, status; -@@ -1639,7 +1639,7 @@ upload_dir_internal(struct sftp_conn *co +@@ -1700,7 +1700,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 printflag, -+upload_dir(struct sftp_conn *conn, const char *src, const char *dst, int printflag, - int pflag) +-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 fsync_flag) { char *dst_canon; -@@ -1656,7 +1656,7 @@ upload_dir(struct sftp_conn *conn, char +@@ -1719,7 +1719,7 @@ upload_dir(struct sftp_conn *conn, char *src, char *dst, int preserve_flag, } char * @@ -545,10 +595,11 @@ diff -up openssh-6.3p1/sftp-client.c.coverity openssh-6.3p1/sftp-client.c { char *ret; size_t len = strlen(p1) + strlen(p2) + 2; -diff -up openssh-6.3p1/sftp-client.h.coverity openssh-6.3p1/sftp-client.h ---- openssh-6.3p1/sftp-client.h.coverity 2013-07-25 03:56:52.000000000 +0200 -+++ openssh-6.3p1/sftp-client.h 2013-10-07 13:45:10.108080813 +0200 -@@ -56,49 +56,49 @@ struct sftp_conn *do_init(int, int, u_in +diff --git a/sftp-client.h b/sftp-client.h +index ba92ad0..c085423 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' */ @@ -598,57 +649,60 @@ diff -up openssh-6.3p1/sftp-client.h.coverity openssh-6.3p1/sftp-client.h int do_statvfs(struct sftp_conn *, const char *, struct sftp_statvfs *, int); /* Rename 'oldpath' to 'newpath' */ --int do_rename(struct sftp_conn *, char *, char *); -+int do_rename(struct sftp_conn *, const char *, const char *); +-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' */ + /* Rename 'oldpath' to 'newpath' */ -int do_symlink(struct sftp_conn *, char *, char *); -+/* Symlink 'oldpath' to 'newpath' */ +int do_symlink(struct sftp_conn *, const char *, const char *); - /* XXX: add callbacks to do_download/do_upload so we can do progress meter */ + /* 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); -@@ -106,27 +106,27 @@ int do_symlink(struct sftp_conn *, char + /* * 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 do_download(struct sftp_conn *, const char *, const char *, Attrib *, int, int); +-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, int); -+int download_dir(struct sftp_conn *, const char *, const char *, Attrib *, int, int, int); +-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 do_upload(struct sftp_conn *, const char *, const char *, int); +-int do_upload(struct sftp_conn *, char *, char *, int, int); ++int do_upload(struct sftp_conn *, const char *, const char *, 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 upload_dir(struct sftp_conn *, const char *, const char *, int, int); +-int upload_dir(struct sftp_conn *, char *, char *, int, int, int); ++int upload_dir(struct sftp_conn *, const char *, const char *, 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 -up openssh-6.3p1/sftp.c.coverity openssh-6.3p1/sftp.c ---- openssh-6.3p1/sftp.c.coverity 2013-07-25 03:56:52.000000000 +0200 -+++ openssh-6.3p1/sftp.c 2013-10-07 13:49:47.322727449 +0200 -@@ -213,7 +213,7 @@ killchild(int signo) +diff --git a/sftp.c b/sftp.c +index ad1f8c8..3987117 100644 +--- a/sftp.c ++++ b/sftp.c +@@ -218,7 +218,7 @@ killchild(int signo) { if (sshpid > 1) { kill(sshpid, SIGTERM); @@ -657,7 +711,7 @@ diff -up openssh-6.3p1/sftp.c.coverity openssh-6.3p1/sftp.c } _exit(1); -@@ -324,7 +324,7 @@ local_do_ls(const char *args) +@@ -329,7 +329,7 @@ local_do_ls(const char *args) /* Strip one path (usually the pwd) from the start of another */ static char * @@ -666,7 +720,7 @@ diff -up openssh-6.3p1/sftp.c.coverity openssh-6.3p1/sftp.c { size_t len; -@@ -342,7 +342,7 @@ path_strip(char *path, char *strip) +@@ -347,7 +347,7 @@ path_strip(char *path, char *strip) } static char * @@ -675,7 +729,7 @@ diff -up openssh-6.3p1/sftp.c.coverity openssh-6.3p1/sftp.c { char *abs_str; -@@ -493,7 +493,7 @@ parse_df_flags(const char *cmd, char **a +@@ -545,7 +545,7 @@ parse_no_flags(const char *cmd, char **argv, int argc) } static int @@ -684,7 +738,7 @@ diff -up openssh-6.3p1/sftp.c.coverity openssh-6.3p1/sftp.c { struct stat sb; -@@ -505,7 +505,7 @@ is_dir(char *path) +@@ -557,7 +557,7 @@ is_dir(char *path) } static int @@ -693,7 +747,7 @@ diff -up openssh-6.3p1/sftp.c.coverity openssh-6.3p1/sftp.c { Attrib *a; -@@ -519,7 +519,7 @@ remote_is_dir(struct sftp_conn *conn, ch +@@ -571,7 +571,7 @@ remote_is_dir(struct sftp_conn *conn, char *path) /* Check whether path returned from glob(..., GLOB_MARK, ...) is a directory */ static int @@ -702,25 +756,25 @@ diff -up openssh-6.3p1/sftp.c.coverity openssh-6.3p1/sftp.c { size_t l = strlen(pathname); -@@ -527,7 +527,7 @@ pathname_is_dir(char *pathname) +@@ -579,7 +579,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 pflag, int rflag, int resume, int fflag) { char *abs_src = NULL; -@@ -605,7 +605,7 @@ out: +@@ -659,7 +659,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 pflag, int rflag, int fflag) { char *tmp_dst = NULL; -@@ -709,7 +709,7 @@ sdirent_comp(const void *aa, const void +@@ -765,7 +765,7 @@ sdirent_comp(const void *aa, const void *bb) /* sftp ls.1 replacement for directories */ static int @@ -729,7 +783,7 @@ diff -up openssh-6.3p1/sftp.c.coverity openssh-6.3p1/sftp.c { int n; u_int c = 1, colspace = 0, columns = 1; -@@ -794,7 +794,7 @@ do_ls_dir(struct sftp_conn *conn, char * +@@ -850,7 +850,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 @@ -738,7 +792,7 @@ diff -up openssh-6.3p1/sftp.c.coverity openssh-6.3p1/sftp.c int lflag) { char *fname, *lname; -@@ -875,7 +875,7 @@ do_globbed_ls(struct sftp_conn *conn, ch +@@ -931,7 +931,7 @@ do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path, } static int @@ -747,10 +801,11 @@ diff -up openssh-6.3p1/sftp.c.coverity openssh-6.3p1/sftp.c { struct sftp_statvfs st; char s_used[FMT_SCALED_STRSIZE]; -diff -up openssh-6.3p1/ssh-agent.c.coverity openssh-6.3p1/ssh-agent.c ---- openssh-6.3p1/ssh-agent.c.coverity 2013-07-20 05:22:49.000000000 +0200 -+++ openssh-6.3p1/ssh-agent.c 2013-10-07 13:20:36.296298024 +0200 -@@ -1143,8 +1143,8 @@ main(int ac, char **av) +diff --git a/ssh-agent.c b/ssh-agent.c +index 117fdde..2b50132 100644 +--- a/ssh-agent.c ++++ b/ssh-agent.c +@@ -1037,8 +1037,8 @@ main(int ac, char **av) sanitise_stdfd(); /* drop */ @@ -761,10 +816,11 @@ diff -up openssh-6.3p1/ssh-agent.c.coverity openssh-6.3p1/ssh-agent.c #if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE) /* Disable ptrace on Linux without sgid bit */ -diff -up openssh-6.3p1/sshd.c.coverity openssh-6.3p1/sshd.c ---- openssh-6.3p1/sshd.c.coverity 2013-07-20 05:21:53.000000000 +0200 -+++ openssh-6.3p1/sshd.c 2013-10-07 13:20:36.296298024 +0200 -@@ -699,8 +699,10 @@ privsep_preauth(Authctxt *authctxt) +diff --git a/sshd.c b/sshd.c +index 773bb02..1eaa9f7 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]"); @@ -776,7 +832,7 @@ diff -up openssh-6.3p1/sshd.c.coverity openssh-6.3p1/sshd.c return 0; } -@@ -1345,6 +1347,9 @@ server_accept_loop(int *sock_in, int *so +@@ -1439,6 +1441,9 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s) if (num_listen_socks < 0) break; } diff --git a/openssh.spec b/openssh.spec index 2d22d13..1d2128f 100644 --- a/openssh.spec +++ b/openssh.spec @@ -93,7 +93,7 @@ Source13: sshd-keygen Patch0: openssh-5.9p1-wIm.patch #? -Patch100: openssh-6.3p1-coverity.patch +Patch100: openssh-6.6.1p1-coverity.patch #https://bugzilla.mindrot.org/show_bug.cgi?id=1872 Patch101: openssh-6.6p1-fingerprint.patch #https://bugzilla.mindrot.org/show_bug.cgi?id=1894 @@ -354,7 +354,6 @@ The module is most useful for su and sudo service stacks. %patch0 -p1 -b .wIm %endif -# rework %patch100 -p1 -b .coverity %patch101 -p1 -b .fingerprint # investigate %patch102 -p1 -b .getaddrinfo %patch103 -p1 -b .packet @@ -424,6 +423,7 @@ popd %patch200 -p1 -b .audit %patch700 -p1 -b .fips +%patch100 -p1 -b .coverity %if 0 # Nothing here yet