]> andersk Git - openssh.git/blobdiff - scp.c
- (stevesk) logintest.c: fix for systems without __progname
[openssh.git] / scp.c
diff --git a/scp.c b/scp.c
index 541ba872644c051e8811cc03a4eba00e3104cbf1..bd2c5c751736f8cb9983867a4620bcafa10a0744 100644 (file)
--- a/scp.c
+++ b/scp.c
@@ -14,8 +14,8 @@
  * called by a name other than "ssh" or "Secure Shell".
  */
 /*
- * Copyright (c) 1999 Theo de Raadt. All rights reserved.
- * Copyright (c) 1999 Aaron Campbell. All rights reserved.
+ * Copyright (c) 1999 Theo de Raadt.  All rights reserved.
+ * Copyright (c) 1999 Aaron Campbell.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -75,7 +75,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: scp.c,v 1.59 2001/02/19 10:36:25 deraadt Exp $");
+RCSID("$OpenBSD: scp.c,v 1.64 2001/03/28 20:04:38 stevesk Exp $");
 
 #include "xmalloc.h"
 #include "atomicio.h"
@@ -202,8 +202,6 @@ typedef struct {
        char *buf;
 } BUF;
 
-extern int iamremote;
-
 BUF *allocbuf(BUF *, int, int);
 char *colon(char *);
 void lostconn(int);
@@ -220,7 +218,6 @@ int pflag, iamremote, iamrecursive, targetshouldbedirectory;
 #define        CMDNEEDS        64
 char cmd[CMDNEEDS];            /* must hold "rcp -r -p -d\0" */
 
-int main(int, char *[]);
 int response(void);
 void rsource(char *, struct stat *);
 void sink(int, char *[]);
@@ -295,7 +292,6 @@ main(argc, argv)
                        iamremote = 1;
                        tflag = 1;
                        break;
-               case '?':
                default:
                        usage();
                }
@@ -545,9 +541,17 @@ syserr:                    run_err("%s: %s", name, strerror(errno));
                                goto next;
                }
 #define        FILEMODEMASK    (S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO)
+#ifdef HAVE_LONG_LONG_INT
+               snprintf(buf, sizeof buf, "C%04o %lld %s\n",
+                   (u_int) (stb.st_mode & FILEMODEMASK),
+                   (long long) stb.st_size, last);
+#else
+               /* XXX: Handle integer overflow? */
                snprintf(buf, sizeof buf, "C%04o %lu %s\n",
                    (u_int) (stb.st_mode & FILEMODEMASK),
                    (u_long) stb.st_size, last);
+#endif
+
                if (verbose_mode) {
                        fprintf(stderr, "Sending file modes: %s", buf);
                        fflush(stderr);
@@ -632,7 +636,7 @@ rsource(name, statp)
                closedir(dirp);
                return;
        }
-       while ((dp = readdir(dirp))) {
+       while ((dp = readdir(dirp)) != NULL) {
                if (dp->d_ino == 0)
                        continue;
                if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
@@ -761,7 +765,7 @@ sink(argc, argv)
                if (*cp++ != ' ')
                        SCREWUP("mode not delimited");
 
-               for (size = 0; *cp >= '0' && *cp <= '9';)
+               for (size = 0; isdigit(*cp);)
                        size = size * 10 + (*cp++ - '0');
                if (*cp++ != ' ')
                        SCREWUP("size not delimited");
@@ -844,7 +848,7 @@ bad:                        run_err("%s: %s", np, strerror(errno));
                                        continue;
                                } else if (j <= 0) {
                                        run_err("%s", j ? strerror(errno) :
-                                               "dropped connection");
+                                           "dropped connection");
                                        exit(1);
                                }
                                amt -= j;
@@ -885,7 +889,7 @@ bad:                        run_err("%s: %s", np, strerror(errno));
                                if (chmod(np, omode))
 #endif /* HAVE_FCHMOD */
                                        run_err("%s: set mode: %s",
-                                               np, strerror(errno));
+                                           np, strerror(errno));
                } else {
                        if (!exists && omode != mode)
 #ifdef HAVE_FCHMOD
@@ -894,7 +898,7 @@ bad:                        run_err("%s: %s", np, strerror(errno));
                                if (chmod(np, omode & ~mask))
 #endif /* HAVE_FCHMOD */
                                        run_err("%s: set mode: %s",
-                                               np, strerror(errno));
+                                           np, strerror(errno));
                }
                if (close(ofd) == -1) {
                        wrerr = YES;
@@ -905,7 +909,7 @@ bad:                        run_err("%s: %s", np, strerror(errno));
                        setimes = 0;
                        if (utimes(np, tv) < 0) {
                                run_err("%s: set times: %s",
-                                       np, strerror(errno));
+                                   np, strerror(errno));
                                wrerr = DISPLAYED;
                        }
                }
@@ -962,8 +966,8 @@ void
 usage()
 {
        (void) fprintf(stderr, "usage: scp "
-           "[-pqrvC46] [-S ssh] [-P port] [-c cipher] [-i identity] f1 f2; or:\n"
-           "       scp [options] f1 ... fn directory\n");
+           "[-pqrvBC46] [-S ssh] [-P port] [-c cipher] [-i identity] f1 f2\n"
+           "   or: scp [options] f1 ... fn directory\n");
        exit(1);
 }
 
This page took 0.039219 seconds and 4 git commands to generate.