summaryrefslogtreecommitdiff
path: root/scp.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2019-10-09 22:59:48 +0100
committerColin Watson <cjwatson@debian.org>2019-10-09 23:39:39 +0100
commit767ee84d3465b6d244a9108de5c167a9ab866df9 (patch)
tree69b14ef6a62d7f133298a21d2ad6046f130b7801 /scp.c
parentddeaf9ee7d5c6612b88f1c4a83fc6fbccb93bf60 (diff)
parentefef12825b9582c1710da3b7e50135870963d4f4 (diff)
New upstream release (8.1p1)
Diffstat (limited to 'scp.c')
-rw-r--r--scp.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/scp.c b/scp.c
index a2dc410bd..5a7a92a7e 100644
--- a/scp.c
+++ b/scp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: scp.c,v 1.204 2019/02/10 11:15:52 djm Exp $ */ 1/* $OpenBSD: scp.c,v 1.206 2019/09/09 02:31:19 dtucker Exp $ */
2/* 2/*
3 * scp - secure remote copy. This is basically patched BSD rcp which 3 * scp - secure remote copy. This is basically patched BSD rcp which
4 * uses ssh to do the data transfer (instead of using rcmd). 4 * uses ssh to do the data transfer (instead of using rcmd).
@@ -101,7 +101,7 @@
101#include <signal.h> 101#include <signal.h>
102#include <stdarg.h> 102#include <stdarg.h>
103#ifdef HAVE_STDINT_H 103#ifdef HAVE_STDINT_H
104#include <stdint.h> 104# include <stdint.h>
105#endif 105#endif
106#include <stdio.h> 106#include <stdio.h>
107#include <stdlib.h> 107#include <stdlib.h>
@@ -261,13 +261,13 @@ do_cmd(char *host, char *remuser, int port, char *cmd, int *fdin, int *fdout)
261 * Reserve two descriptors so that the real pipes won't get 261 * Reserve two descriptors so that the real pipes won't get
262 * descriptors 0 and 1 because that will screw up dup2 below. 262 * descriptors 0 and 1 because that will screw up dup2 below.
263 */ 263 */
264 if (pipe(reserved) < 0) 264 if (pipe(reserved) == -1)
265 fatal("pipe: %s", strerror(errno)); 265 fatal("pipe: %s", strerror(errno));
266 266
267 /* Create a socket pair for communicating with ssh. */ 267 /* Create a socket pair for communicating with ssh. */
268 if (pipe(pin) < 0) 268 if (pipe(pin) == -1)
269 fatal("pipe: %s", strerror(errno)); 269 fatal("pipe: %s", strerror(errno));
270 if (pipe(pout) < 0) 270 if (pipe(pout) == -1)
271 fatal("pipe: %s", strerror(errno)); 271 fatal("pipe: %s", strerror(errno));
272 272
273 /* Free the reserved descriptors. */ 273 /* Free the reserved descriptors. */
@@ -1074,7 +1074,7 @@ source(int argc, char **argv)
1074 off_t i, statbytes; 1074 off_t i, statbytes;
1075 size_t amt, nr; 1075 size_t amt, nr;
1076 int fd = -1, haderr, indx; 1076 int fd = -1, haderr, indx;
1077 char *last, *name, buf[2048], encname[PATH_MAX]; 1077 char *last, *name, buf[PATH_MAX + 128], encname[PATH_MAX];
1078 int len; 1078 int len;
1079 1079
1080 for (indx = 0; indx < argc; ++indx) { 1080 for (indx = 0; indx < argc; ++indx) {
@@ -1083,13 +1083,13 @@ source(int argc, char **argv)
1083 len = strlen(name); 1083 len = strlen(name);
1084 while (len > 1 && name[len-1] == '/') 1084 while (len > 1 && name[len-1] == '/')
1085 name[--len] = '\0'; 1085 name[--len] = '\0';
1086 if ((fd = open(name, O_RDONLY|O_NONBLOCK, 0)) < 0) 1086 if ((fd = open(name, O_RDONLY|O_NONBLOCK, 0)) == -1)
1087 goto syserr; 1087 goto syserr;
1088 if (strchr(name, '\n') != NULL) { 1088 if (strchr(name, '\n') != NULL) {
1089 strnvis(encname, name, sizeof(encname), VIS_NL); 1089 strnvis(encname, name, sizeof(encname), VIS_NL);
1090 name = encname; 1090 name = encname;
1091 } 1091 }
1092 if (fstat(fd, &stb) < 0) { 1092 if (fstat(fd, &stb) == -1) {
1093syserr: run_err("%s: %s", name, strerror(errno)); 1093syserr: run_err("%s: %s", name, strerror(errno));
1094 goto next; 1094 goto next;
1095 } 1095 }
@@ -1163,7 +1163,7 @@ next: if (fd != -1) {
1163 unset_nonblock(remout); 1163 unset_nonblock(remout);
1164 1164
1165 if (fd != -1) { 1165 if (fd != -1) {
1166 if (close(fd) < 0 && !haderr) 1166 if (close(fd) == -1 && !haderr)
1167 haderr = errno; 1167 haderr = errno;
1168 fd = -1; 1168 fd = -1;
1169 } 1169 }
@@ -1427,14 +1427,14 @@ sink(int argc, char **argv, const char *src)
1427 /* Handle copying from a read-only 1427 /* Handle copying from a read-only
1428 directory */ 1428 directory */
1429 mod_flag = 1; 1429 mod_flag = 1;
1430 if (mkdir(np, mode | S_IRWXU) < 0) 1430 if (mkdir(np, mode | S_IRWXU) == -1)
1431 goto bad; 1431 goto bad;
1432 } 1432 }
1433 vect[0] = xstrdup(np); 1433 vect[0] = xstrdup(np);
1434 sink(1, vect, src); 1434 sink(1, vect, src);
1435 if (setimes) { 1435 if (setimes) {
1436 setimes = 0; 1436 setimes = 0;
1437 if (utimes(vect[0], tv) < 0) 1437 if (utimes(vect[0], tv) == -1)
1438 run_err("%s: set times: %s", 1438 run_err("%s: set times: %s",
1439 vect[0], strerror(errno)); 1439 vect[0], strerror(errno));
1440 } 1440 }
@@ -1445,7 +1445,7 @@ sink(int argc, char **argv, const char *src)
1445 } 1445 }
1446 omode = mode; 1446 omode = mode;
1447 mode |= S_IWUSR; 1447 mode |= S_IWUSR;
1448 if ((ofd = open(np, O_WRONLY|O_CREAT, mode)) < 0) { 1448 if ((ofd = open(np, O_WRONLY|O_CREAT, mode)) == -1) {
1449bad: run_err("%s: %s", np, strerror(errno)); 1449bad: run_err("%s: %s", np, strerror(errno));
1450 continue; 1450 continue;
1451 } 1451 }
@@ -1535,7 +1535,7 @@ bad: run_err("%s: %s", np, strerror(errno));
1535 stop_progress_meter(); 1535 stop_progress_meter();
1536 if (setimes && wrerr == NO) { 1536 if (setimes && wrerr == NO) {
1537 setimes = 0; 1537 setimes = 0;
1538 if (utimes(np, tv) < 0) { 1538 if (utimes(np, tv) == -1) {
1539 run_err("%s: set times: %s", 1539 run_err("%s: set times: %s",
1540 np, strerror(errno)); 1540 np, strerror(errno));
1541 wrerr = DISPLAYED; 1541 wrerr = DISPLAYED;
@@ -1689,7 +1689,7 @@ allocbuf(BUF *bp, int fd, int blksize)
1689#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE 1689#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
1690 struct stat stb; 1690 struct stat stb;
1691 1691
1692 if (fstat(fd, &stb) < 0) { 1692 if (fstat(fd, &stb) == -1) {
1693 run_err("fstat: %s", strerror(errno)); 1693 run_err("fstat: %s", strerror(errno));
1694 return (0); 1694 return (0);
1695 } 1695 }