summaryrefslogtreecommitdiff
path: root/scp.c
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2023-03-03 03:12:24 +0000
committerDarren Tucker <dtucker@dtucker.net>2023-03-03 14:49:14 +1100
commit93291bd723959adf462b1df958106cf07a7734dd (patch)
tree58634fad8d21def16996650e9d86ddff530b06e3 /scp.c
parente37261dff33af23f37202cfce0848d36f5c1055c (diff)
downloadopenssh-git-93291bd723959adf462b1df958106cf07a7734dd.tar.gz
upstream: Check return values of dup2. Spotted by Coverity, ok djm@
OpenBSD-Commit-ID: 19fb1b53072826d00c67df677731d2f6c1dd602b
Diffstat (limited to 'scp.c')
-rw-r--r--scp.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/scp.c b/scp.c
index 1adff5ce..a893d4a2 100644
--- a/scp.c
+++ b/scp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scp.c,v 1.252 2023/01/10 23:22:15 millert Exp $ */
+/* $OpenBSD: scp.c,v 1.253 2023/03/03 03:12:24 dtucker Exp $ */
/*
* scp - secure remote copy. This is basically patched BSD rcp which
* uses ssh to do the data transfer (instead of using rcmd).
@@ -394,8 +394,10 @@ do_cmd2(char *host, char *remuser, int port, char *cmd,
/* Fork a child to execute the command on the remote host using ssh. */
pid = fork();
if (pid == 0) {
- dup2(fdin, 0);
- dup2(fdout, 1);
+ if (dup2(fdin, 0) == -1)
+ perror("dup2");
+ if (dup2(fdout, 1) == -1)
+ perror("dup2");
replacearg(&args, 0, "%s", ssh_program);
if (port != -1) {