*/
#include "includes.h"
-RCSID("$OpenBSD: scp.c,v 1.110 2003/10/08 08:27:36 jmc Exp $");
+RCSID("$OpenBSD: scp.c,v 1.114 2004/04/01 12:19:57 markus Exp $");
#include "xmalloc.h"
#include "atomicio.h"
arglist args;
/* Bandwidth limit */
-off_t limitbw = 0;
+off_t limit_rate = 0;
/* Name of current file being transferred. */
char *curfile;
speed = strtod(optarg, &endp);
if (speed <= 0 || *endp != '\0')
usage();
- limitbw = speed * 1024;
+ limit_rate = speed * 1024;
break;
case 'p':
pflag = 1;
verbose_mode = 1;
break;
case 'q':
+ addargs(&args, "-q");
showprogress = 0;
break;
haderr = result >= 0 ? EIO : errno;
statbytes += result;
}
- if (limitbw)
+ if (limit_rate)
bwlimit(amt);
}
if (showprogress)
return;
lamt *= 8;
- wait = (double)1000000L * lamt / limitbw;
+ wait = (double)1000000L * lamt / limit_rate;
bwstart.tv_sec = wait / 1000000L;
bwstart.tv_usec = wait % 1000000L;
*cp++ = ch;
} while (cp < &buf[sizeof(buf) - 1] && ch != '\n');
*cp = 0;
+ if (verbose_mode)
+ fprintf(stderr, "Sink: %s", buf);
if (buf[0] == '\01' || buf[0] == '\02') {
if (iamremote == 0)
size = size * 10 + (*cp++ - '0');
if (*cp++ != ' ')
SCREWUP("size not delimited");
+ if ((strchr(cp, '/') != NULL) || (strcmp(cp, "..") == 0)) {
+ run_err("error: unexpected filename: %s", cp);
+ exit(1);
+ }
if (targisdir) {
static char *namebuf;
static int cursize;
exists = stat(np, &stb) == 0;
if (buf[0] == 'D') {
int mod_flag = pflag;
+ if (!iamrecursive)
+ SCREWUP("received directory without -r");
if (exists) {
if (!S_ISDIR(stb.st_mode)) {
errno = ENOTDIR;
cp += j;
statbytes += j;
} while (amt > 0);
-
- if (limitbw)
+
+ if (limit_rate)
bwlimit(4096);
if (count == bp->cnt) {