Date: Fri, 6 Oct 2006 04:51:34 GMT From: Geoffrey Giesemann <geoffwa@cs.rmit.edu.au> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/104039: [patch] cp's SIGINFO handler percent complete status wraps around when the bytes copied exceeds size_t Message-ID: <200610060451.k964pYEM004621@www.freebsd.org> Resent-Message-ID: <200610060500.k9650h5p061589@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 104039 >Category: bin >Synopsis: [patch] cp's SIGINFO handler percent complete status wraps around when the bytes copied exceeds size_t >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Oct 06 05:00:38 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Geoffrey Giesemann >Release: 6.2-PRERELEASE >Organization: >Environment: FreeBSD geoff.cs.rmit.edu.au 6.2-PRERELEASE FreeBSD 6.2-PRERELEASE #10: Thu Oct 5 14:44:56 EST 2006 root@geoff.cs.rmit.edu.au:/usr/obj/usr/src/sys/GEOFF i386 >Description: cp keeps a running total of the bytes copied, so that when it gets a SIGINFO it can print a percentage copied. The variable is of type size_t, so when bytes copied exceeds 4GB, it wraps to a negative value. Changing the type to off_t fixes this. >How-To-Repeat: dd if=/dev/zero of=/somewhere/with/lotsa/space/file bs=512 count=10M cp /somewhere/with/lotsa/space/file /somewhere/with/lotsa/space/file2 <hammer ^T> >Fix: Change type of wtotal to off_t: --- /usr/src/bin/cp/utils_old.c Fri Oct 6 14:05:34 2006 +++ /usr/src/bin/cp/utils.c Fri Oct 6 14:25:19 2006 @@ -64,7 +64,7 @@ int ch, checkch, from_fd = 0, rcount, rval, to_fd = 0; ssize_t wcount; size_t wresid; - size_t wtotal; + off_t wtotal; char *bufp; #ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED char *p; >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610060451.k964pYEM004621>