diff options
author | 2008-06-13 18:55:22 +0000 | |
---|---|---|
committer | 2008-06-13 18:55:22 +0000 | |
commit | de00de232da4d033fb61401aa27937a97c3fc155 (patch) | |
tree | 76c516863d18dddb99bc94fa529c7402ec68a882 | |
parent | Remove mail-mode. It was a buggy reimplementation of auto-fill-mode. (diff) | |
download | wireguard-openbsd-de00de232da4d033fb61401aa27937a97c3fc155.tar.xz wireguard-openbsd-de00de232da4d033fb61401aa27937a97c3fc155.zip |
Prevent -Wsign-compare warnings on LP64 systems. bz #1192, ok deraadt@
-rw-r--r-- | usr.bin/ssh/scp.c | 11 |
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) |