diff options
author | dtucker@openbsd.org <dtucker@openbsd.org> | 2023-03-03 03:12:24 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@dtucker.net> | 2023-03-03 14:49:14 +1100 |
commit | 93291bd723959adf462b1df958106cf07a7734dd (patch) | |
tree | 58634fad8d21def16996650e9d86ddff530b06e3 /sshd.c | |
parent | e37261dff33af23f37202cfce0848d36f5c1055c (diff) | |
download | openssh-git-93291bd723959adf462b1df958106cf07a7734dd.tar.gz |
upstream: Check return values of dup2. Spotted by Coverity, ok djm@
OpenBSD-Commit-ID: 19fb1b53072826d00c67df677731d2f6c1dd602b
Diffstat (limited to 'sshd.c')
-rw-r--r-- | sshd.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: sshd.c,v 1.597 2023/02/10 04:47:19 djm Exp $ */ +/* $OpenBSD: sshd.c,v 1.598 2023/03/03 03:12:24 dtucker Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -2117,17 +2117,21 @@ main(int ac, char **av) if (rexec_flag) { debug("rexec start in %d out %d newsock %d pipe %d sock %d", sock_in, sock_out, newsock, startup_pipe, config_s[0]); - dup2(newsock, STDIN_FILENO); - dup2(STDIN_FILENO, STDOUT_FILENO); + if (dup2(newsock, STDIN_FILENO) == -1) + debug3_f("dup2 stdin: %s", strerror(errno)); + if (dup2(STDIN_FILENO, STDOUT_FILENO) == -1) + debug3_f("dup2 stdout: %s", strerror(errno)); if (startup_pipe == -1) close(REEXEC_STARTUP_PIPE_FD); else if (startup_pipe != REEXEC_STARTUP_PIPE_FD) { - dup2(startup_pipe, REEXEC_STARTUP_PIPE_FD); + if (dup2(startup_pipe, REEXEC_STARTUP_PIPE_FD) == -1) + debug3_f("dup2 startup_p: %s", strerror(errno)); close(startup_pipe); startup_pipe = REEXEC_STARTUP_PIPE_FD; } - dup2(config_s[1], REEXEC_CONFIG_PASS_FD); + if (dup2(config_s[1], REEXEC_CONFIG_PASS_FD) == -1) + debug3_f("dup2 config_s: %s", strerror(errno)); close(config_s[1]); ssh_signal(SIGHUP, SIG_IGN); /* avoid reset to SIG_DFL */ |