summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/scp.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@cvs.openbsd.org>2008-06-13 18:55:23 +0000
committerDarren Tucker <dtucker@cvs.openbsd.org>2008-06-13 18:55:23 +0000
commit589e61ea4113959d3e6f89ccd6a13ac56a596f8b (patch)
treeb56faaaa352d41860e4b22ea34a70aaebf80078f /usr.bin/ssh/scp.c
parentbc3cf8f2dd4319c8084b83c7207431fb5935e0f6 (diff)
Prevent -Wsign-compare warnings on LP64 systems. bz #1192, ok deraadt@
Diffstat (limited to 'usr.bin/ssh/scp.c')
-rw-r--r--usr.bin/ssh/scp.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/ssh/scp.c b/usr.bin/ssh/scp.c
index 3dce8eea773..e3b4b683cdb 100644
--- a/usr.bin/ssh/scp.c
+++ b/usr.bin/ssh/scp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scp.c,v 1.162 2008/01/01 09:06:39 dtucker Exp $ */
+/* $OpenBSD: scp.c,v 1.163 2008/06/13 18:55:22 dtucker Exp $ */
/*
* scp - secure remote copy. This is basically patched BSD rcp which
* uses ssh to do the data transfer (instead of using rcmd).
@@ -607,7 +607,8 @@ source(int argc, char **argv)
struct stat stb;
static BUF buffer;
BUF *bp;
- off_t i, amt, statbytes;
+ off_t i, statbytes;
+ size_t amt;
int fd = -1, haderr, indx;
char *last, *name, buf[2048], encname[MAXPATHLEN];
int len;
@@ -628,6 +629,10 @@ source(int argc, char **argv)
syserr: run_err("%s: %s", name, strerror(errno));
goto next;
}
+ if (stb.st_size < 0) {
+ run_err("%s: %s", name, "Negative file size");
+ goto next;
+ }
unset_nonblock(fd);
switch (stb.st_mode & S_IFMT) {
case S_IFREG:
@@ -687,7 +692,7 @@ next: if (fd != -1) {
set_nonblock(remout);
for (haderr = i = 0; i < stb.st_size; i += bp->cnt) {
amt = bp->cnt;
- if (i + amt > stb.st_size)
+ if (i + (off_t)amt > stb.st_size)
amt = stb.st_size - i;
if (!haderr) {
if (atomicio(read, fd, bp->buf, amt) != amt)