From 03ccc9b142519ac8167951fac27d977dc280b79a Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Sat, 14 Jun 2008 09:02:25 +1000 Subject: - dtucker@cvs.openbsd.org 2008/06/13 18:55:22 [scp.c] Prevent -Wsign-compare warnings on LP64 systems. bz #1192, ok deraadt@ --- ChangeLog | 5 ++++- scp.c | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b7387c56..7279a819f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,9 @@ - dtucker@cvs.openbsd.org 2008/06/13 17:21:20 [mux.c] Friendlier error messages for mux fallback. ok djm@ + - dtucker@cvs.openbsd.org 2008/06/13 18:55:22 + [scp.c] + Prevent -Wsign-compare warnings on LP64 systems. bz #1192, ok deraadt@ 20080612 - (dtucker) OpenBSD CVS Sync @@ -4353,4 +4356,4 @@ OpenServer 6 and add osr5bigcrypt support so when someone migrates passwords between UnixWare and OpenServer they will still work. OK dtucker@ -$Id: ChangeLog,v 1.5007 2008/06/13 23:01:54 dtucker Exp $ +$Id: ChangeLog,v 1.5008 2008/06/13 23:02:25 dtucker Exp $ diff --git a/scp.c b/scp.c index c047864aa..46433a638 100644 --- a/scp.c +++ b/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). @@ -629,7 +629,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; @@ -650,6 +651,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: @@ -709,7 +714,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) -- cgit v1.2.3