From 93291bd723959adf462b1df958106cf07a7734dd Mon Sep 17 00:00:00 2001 From: "dtucker@openbsd.org" Date: Fri, 3 Mar 2023 03:12:24 +0000 Subject: upstream: Check return values of dup2. Spotted by Coverity, ok djm@ OpenBSD-Commit-ID: 19fb1b53072826d00c67df677731d2f6c1dd602b --- scp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'scp.c') 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) { -- cgit v1.2.1