View | Details | Raw Unified | Return to bug 2581 | Differences between
and this patch

Collapse All | Expand All

(-)a/auth-pam.c (-1 / +6 lines)
Lines 217-223 pthread_join(sp_pthread_t thread, void **value) Link Here
217
	if (sshpam_thread_status != -1)
217
	if (sshpam_thread_status != -1)
218
		return (sshpam_thread_status);
218
		return (sshpam_thread_status);
219
	signal(SIGCHLD, sshpam_oldsig);
219
	signal(SIGCHLD, sshpam_oldsig);
220
	waitpid(thread, &status, 0);
220
	while (waitpid(thread, &status, 0) < 0) {
221
		if (errno == EINTR)
222
			continue;
223
		fatal("%s: waitpid: %s", __func__,
224
				strerror(errno));
225
	}
221
	return (status);
226
	return (status);
222
}
227
}
223
#endif
228
#endif
(-)a/channels.c (-6 / +6 lines)
Lines 246-256 channel_register_fds(Channel *c, int rfd, int wfd, int efd, Link Here
246
	channel_max_fd = MAX(channel_max_fd, wfd);
246
	channel_max_fd = MAX(channel_max_fd, wfd);
247
	channel_max_fd = MAX(channel_max_fd, efd);
247
	channel_max_fd = MAX(channel_max_fd, efd);
248
248
249
	if (rfd != -1)
249
	if (rfd >= 0)
250
		fcntl(rfd, F_SETFD, FD_CLOEXEC);
250
		fcntl(rfd, F_SETFD, FD_CLOEXEC);
251
	if (wfd != -1 && wfd != rfd)
251
	if (wfd >= 0 && wfd != rfd)
252
		fcntl(wfd, F_SETFD, FD_CLOEXEC);
252
		fcntl(wfd, F_SETFD, FD_CLOEXEC);
253
	if (efd != -1 && efd != rfd && efd != wfd)
253
	if (efd >= 0 && efd != rfd && efd != wfd)
254
		fcntl(efd, F_SETFD, FD_CLOEXEC);
254
		fcntl(efd, F_SETFD, FD_CLOEXEC);
255
255
256
	c->rfd = rfd;
256
	c->rfd = rfd;
Lines 268-278 channel_register_fds(Channel *c, int rfd, int wfd, int efd, Link Here
268
268
269
	/* enable nonblocking mode */
269
	/* enable nonblocking mode */
270
	if (nonblock) {
270
	if (nonblock) {
271
		if (rfd != -1)
271
		if (rfd >= 0)
272
			set_nonblock(rfd);
272
			set_nonblock(rfd);
273
		if (wfd != -1)
273
		if (wfd >= 0)
274
			set_nonblock(wfd);
274
			set_nonblock(wfd);
275
		if (efd != -1)
275
		if (efd >= 0)
276
			set_nonblock(efd);
276
			set_nonblock(efd);
277
	}
277
	}
278
}
278
}
(-)a/monitor.c (-1 / +1 lines)
Lines 420-426 monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor) Link Here
420
	mm_get_keystate(pmonitor);
420
	mm_get_keystate(pmonitor);
421
421
422
	/* Drain any buffered messages from the child */
422
	/* Drain any buffered messages from the child */
423
	while (pmonitor->m_log_recvfd != -1 && monitor_read_log(pmonitor) == 0)
423
	while (pmonitor->m_log_recvfd >= 0 && monitor_read_log(pmonitor) == 0)
424
		;
424
		;
425
425
426
	close(pmonitor->m_sendfd);
426
	close(pmonitor->m_sendfd);
(-)a/scp.c (-1 / +1 lines)
Lines 156-162 killchild(int signo) Link Here
156
{
156
{
157
	if (do_cmd_pid > 1) {
157
	if (do_cmd_pid > 1) {
158
		kill(do_cmd_pid, signo ? signo : SIGTERM);
158
		kill(do_cmd_pid, signo ? signo : SIGTERM);
159
		waitpid(do_cmd_pid, NULL, 0);
159
		(void) waitpid(do_cmd_pid, NULL, 0);
160
	}
160
	}
161
161
162
	if (signo)
162
	if (signo)
(-)a/servconf.c (-1 / +1 lines)
Lines 1502-1508 process_server_config_line(ServerOptions *options, char *line, Link Here
1502
			fatal("%s line %d: Missing subsystem name.",
1502
			fatal("%s line %d: Missing subsystem name.",
1503
			    filename, linenum);
1503
			    filename, linenum);
1504
		if (!*activep) {
1504
		if (!*activep) {
1505
			arg = strdelim(&cp);
1505
			(void) strdelim(&cp);
1506
			break;
1506
			break;
1507
		}
1507
		}
1508
		for (i = 0; i < options->num_subsystems; i++)
1508
		for (i = 0; i < options->num_subsystems; i++)
(-)a/serverloop.c (-11 / +11 lines)
Lines 146-158 notify_setup(void) Link Here
146
static void
146
static void
147
notify_parent(void)
147
notify_parent(void)
148
{
148
{
149
	if (notify_pipe[1] != -1)
149
	if (notify_pipe[1] >= 0)
150
		(void)write(notify_pipe[1], "", 1);
150
		(void)write(notify_pipe[1], "", 1);
151
}
151
}
152
static void
152
static void
153
notify_prepare(fd_set *readset)
153
notify_prepare(fd_set *readset)
154
{
154
{
155
	if (notify_pipe[0] != -1)
155
	if (notify_pipe[0] >= 0)
156
		FD_SET(notify_pipe[0], readset);
156
		FD_SET(notify_pipe[0], readset);
157
}
157
}
158
static void
158
static void
Lines 160-166 notify_done(fd_set *readset) Link Here
160
{
160
{
161
	char c;
161
	char c;
162
162
163
	if (notify_pipe[0] != -1 && FD_ISSET(notify_pipe[0], readset))
163
	if (notify_pipe[0] >= 0 && FD_ISSET(notify_pipe[0], readset))
164
		while (read(notify_pipe[0], &c, 1) != -1)
164
		while (read(notify_pipe[0], &c, 1) != -1)
165
			debug2("notify_done: reading");
165
			debug2("notify_done: reading");
166
}
166
}
Lines 338-344 wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp, Link Here
338
		 * If we have buffered data, try to write some of that data
338
		 * If we have buffered data, try to write some of that data
339
		 * to the program.
339
		 * to the program.
340
		 */
340
		 */
341
		if (fdin != -1 && buffer_len(&stdin_buffer) > 0)
341
		if (fdin >= 0 && buffer_len(&stdin_buffer) > 0)
342
			FD_SET(fdin, *writesetp);
342
			FD_SET(fdin, *writesetp);
343
	}
343
	}
344
	notify_prepare(*readsetp);
344
	notify_prepare(*readsetp);
Lines 477-483 process_output(fd_set *writeset) Link Here
477
	int len;
477
	int len;
478
478
479
	/* Write buffered data to program stdin. */
479
	/* Write buffered data to program stdin. */
480
	if (!compat20 && fdin != -1 && FD_ISSET(fdin, writeset)) {
480
	if (!compat20 && fdin >= 0 && FD_ISSET(fdin, writeset)) {
481
		data = buffer_ptr(&stdin_buffer);
481
		data = buffer_ptr(&stdin_buffer);
482
		dlen = buffer_len(&stdin_buffer);
482
		dlen = buffer_len(&stdin_buffer);
483
		len = write(fdin, data, dlen);
483
		len = write(fdin, data, dlen);
Lines 590-596 server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg) Link Here
590
	set_nonblock(fdin);
590
	set_nonblock(fdin);
591
	set_nonblock(fdout);
591
	set_nonblock(fdout);
592
	/* we don't have stderr for interactive terminal sessions, see below */
592
	/* we don't have stderr for interactive terminal sessions, see below */
593
	if (fderr != -1)
593
	if (fderr >= 0)
594
		set_nonblock(fderr);
594
		set_nonblock(fderr);
595
595
596
	if (!(datafellows & SSH_BUG_IGNOREMSG) && isatty(fdin))
596
	if (!(datafellows & SSH_BUG_IGNOREMSG) && isatty(fdin))
Lines 644-650 server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg) Link Here
644
		 * If we have received eof, and there is no more pending
644
		 * If we have received eof, and there is no more pending
645
		 * input data, cause a real eof by closing fdin.
645
		 * input data, cause a real eof by closing fdin.
646
		 */
646
		 */
647
		if (stdin_eof && fdin != -1 && buffer_len(&stdin_buffer) == 0) {
647
		if (stdin_eof && fdin >= 0 && buffer_len(&stdin_buffer) == 0) {
648
			if (fdin != fdout)
648
			if (fdin != fdout)
649
				close(fdin);
649
				close(fdin);
650
			else
650
			else
Lines 740-754 server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg) Link Here
740
	buffer_free(&stderr_buffer);
740
	buffer_free(&stderr_buffer);
741
741
742
	/* Close the file descriptors. */
742
	/* Close the file descriptors. */
743
	if (fdout != -1)
743
	if (fdout >= 0)
744
		close(fdout);
744
		close(fdout);
745
	fdout = -1;
745
	fdout = -1;
746
	fdout_eof = 1;
746
	fdout_eof = 1;
747
	if (fderr != -1)
747
	if (fderr >= 0)
748
		close(fderr);
748
		close(fderr);
749
	fderr = -1;
749
	fderr = -1;
750
	fderr_eof = 1;
750
	fderr_eof = 1;
751
	if (fdin != -1)
751
	if (fdin >= 0)
752
		close(fdin);
752
		close(fdin);
753
	fdin = -1;
753
	fdin = -1;
754
754
Lines 944-950 server_input_window_size(int type, u_int32_t seq, void *ctxt) Link Here
944
944
945
	debug("Window change received.");
945
	debug("Window change received.");
946
	packet_check_eom();
946
	packet_check_eom();
947
	if (fdin != -1)
947
	if (fdin >= 0)
948
		pty_change_window_size(fdin, row, col, xpixel, ypixel);
948
		pty_change_window_size(fdin, row, col, xpixel, ypixel);
949
	return 0;
949
	return 0;
950
}
950
}
(-)a/sftp.c (-13 / +13 lines)
Lines 223-229 killchild(int signo) Link Here
223
{
223
{
224
	if (sshpid > 1) {
224
	if (sshpid > 1) {
225
		kill(sshpid, SIGTERM);
225
		kill(sshpid, SIGTERM);
226
		waitpid(sshpid, NULL, 0);
226
		(void) waitpid(sshpid, NULL, 0);
227
	}
227
	}
228
228
229
	_exit(1);
229
	_exit(1);
Lines 335-341 local_do_ls(const char *args) Link Here
335
335
336
/* Strip one path (usually the pwd) from the start of another */
336
/* Strip one path (usually the pwd) from the start of another */
337
static char *
337
static char *
338
path_strip(char *path, char *strip)
338
path_strip(const char *path, const char *strip)
339
{
339
{
340
	size_t len;
340
	size_t len;
341
341
Lines 353-359 path_strip(char *path, char *strip) Link Here
353
}
353
}
354
354
355
static char *
355
static char *
356
make_absolute(char *p, char *pwd)
356
make_absolute(char *p, const char *pwd)
357
{
357
{
358
	char *abs_str;
358
	char *abs_str;
359
359
Lines 551-557 parse_no_flags(const char *cmd, char **argv, int argc) Link Here
551
}
551
}
552
552
553
static int
553
static int
554
is_dir(char *path)
554
is_dir(const char *path)
555
{
555
{
556
	struct stat sb;
556
	struct stat sb;
557
557
Lines 563-569 is_dir(char *path) Link Here
563
}
563
}
564
564
565
static int
565
static int
566
remote_is_dir(struct sftp_conn *conn, char *path)
566
remote_is_dir(struct sftp_conn *conn, const char *path)
567
{
567
{
568
	Attrib *a;
568
	Attrib *a;
569
569
Lines 577-583 remote_is_dir(struct sftp_conn *conn, char *path) Link Here
577
577
578
/* Check whether path returned from glob(..., GLOB_MARK, ...) is a directory */
578
/* Check whether path returned from glob(..., GLOB_MARK, ...) is a directory */
579
static int
579
static int
580
pathname_is_dir(char *pathname)
580
pathname_is_dir(const char *pathname)
581
{
581
{
582
	size_t l = strlen(pathname);
582
	size_t l = strlen(pathname);
583
583
Lines 585-592 pathname_is_dir(char *pathname) Link Here
585
}
585
}
586
586
587
static int
587
static int
588
process_get(struct sftp_conn *conn, char *src, char *dst, char *pwd,
588
process_get(struct sftp_conn *conn, const char *src, const char *dst,
589
    int pflag, int rflag, int resume, int fflag)
589
    const char *pwd, int pflag, int rflag, int resume, int fflag)
590
{
590
{
591
	char *abs_src = NULL;
591
	char *abs_src = NULL;
592
	char *abs_dst = NULL;
592
	char *abs_dst = NULL;
Lines 669-676 out: Link Here
669
}
669
}
670
670
671
static int
671
static int
672
process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd,
672
process_put(struct sftp_conn *conn, const char *src, const char *dst,
673
    int pflag, int rflag, int resume, int fflag)
673
    const char *pwd, int pflag, int rflag, int resume, int fflag)
674
{
674
{
675
	char *tmp_dst = NULL;
675
	char *tmp_dst = NULL;
676
	char *abs_dst = NULL;
676
	char *abs_dst = NULL;
Lines 779-785 sdirent_comp(const void *aa, const void *bb) Link Here
779
779
780
/* sftp ls.1 replacement for directories */
780
/* sftp ls.1 replacement for directories */
781
static int
781
static int
782
do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
782
do_ls_dir(struct sftp_conn *conn, const char *path, const char *strip_path, int lflag)
783
{
783
{
784
	int n;
784
	int n;
785
	u_int c = 1, colspace = 0, columns = 1;
785
	u_int c = 1, colspace = 0, columns = 1;
Lines 864-870 do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag) Link Here
864
864
865
/* sftp ls.1 replacement which handles path globs */
865
/* sftp ls.1 replacement which handles path globs */
866
static int
866
static int
867
do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
867
do_globbed_ls(struct sftp_conn *conn, const char *path, const char *strip_path,
868
    int lflag)
868
    int lflag)
869
{
869
{
870
	char *fname, *lname;
870
	char *fname, *lname;
Lines 949-955 do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path, Link Here
949
}
949
}
950
950
951
static int
951
static int
952
do_df(struct sftp_conn *conn, char *path, int hflag, int iflag)
952
do_df(struct sftp_conn *conn, const char *path, int hflag, int iflag)
953
{
953
{
954
	struct sftp_statvfs st;
954
	struct sftp_statvfs st;
955
	char s_used[FMT_SCALED_STRSIZE];
955
	char s_used[FMT_SCALED_STRSIZE];
(-)a/ssh-agent.c (-2 / +2 lines)
Lines 1206-1213 main(int ac, char **av) Link Here
1206
	sanitise_stdfd();
1206
	sanitise_stdfd();
1207
1207
1208
	/* drop */
1208
	/* drop */
1209
	setegid(getgid());
1209
	(void) setegid(getgid());
1210
	setgid(getgid());
1210
	(void) setgid(getgid());
1211
1211
1212
#if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
1212
#if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
1213
	/* Disable ptrace on Linux without sgid bit */
1213
	/* Disable ptrace on Linux without sgid bit */

Return to bug 2581