bin/104039: [patch] cp's SIGINFO handler percent complete status
wraps around when the bytes copied exceeds size_t
Geoffrey Giesemann
geoffwa at cs.rmit.edu.au
Thu Oct 5 22:00:44 PDT 2006
>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 at 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:
More information about the freebsd-bugs
mailing list