diff options
author | pi <pi@FreeBSD.org> | 2014-10-27 11:38:17 +0000 |
---|---|---|
committer | pi <pi@FreeBSD.org> | 2014-10-27 11:38:17 +0000 |
commit | 0b6ca5ce8d93243ce9ba40f73265d2c18b2c6c8a (patch) | |
tree | 6ba85fb34df7f3808f134f2cbad46ca47fb9ee12 /bin/dd/dd.h | |
parent | d92cafa3fcdd7ad1398b1373446e03dbbc40154c (diff) | |
download | FreeBSD-src-0b6ca5ce8d93243ce9ba40f73265d2c18b2c6c8a.zip FreeBSD-src-0b6ca5ce8d93243ce9ba40f73265d2c18b2c6c8a.tar.gz |
bin/dd: Fix incorrect casting of arguments
dd(1) casts many of its numeric arguments from uintmax_t to intmax_t
and back again to detect whether or not the original arguments were
negative. This caused wrong behaviour in some boundary cases:
$ dd if=/dev/zero of=/dev/null count=18446744073709551615
dd: count cannot be negative
After the fix:
$ dd if=/dev/zero of=/dev/null count=18446744073709551615
dd: count: Result too large
PR: 191263
Submitted by: will@worrbase.com
Approved by: cognet@
Diffstat (limited to 'bin/dd/dd.h')
-rw-r--r-- | bin/dd/dd.h | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/bin/dd/dd.h b/bin/dd/dd.h index a8b45e5..42892ad 100644 --- a/bin/dd/dd.h +++ b/bin/dd/dd.h @@ -38,10 +38,9 @@ typedef struct { u_char *db; /* buffer address */ u_char *dbp; /* current buffer I/O address */ - /* XXX ssize_t? */ - size_t dbcnt; /* current buffer byte count */ - size_t dbrcnt; /* last read byte count */ - size_t dbsz; /* block size */ + ssize_t dbcnt; /* current buffer byte count */ + ssize_t dbrcnt; /* last read byte count */ + ssize_t dbsz; /* block size */ #define ISCHR 0x01 /* character device (warn on short) */ #define ISPIPE 0x02 /* pipe-like (see position.c) */ @@ -57,13 +56,13 @@ typedef struct { } IO; typedef struct { - uintmax_t in_full; /* # of full input blocks */ - uintmax_t in_part; /* # of partial input blocks */ - uintmax_t out_full; /* # of full output blocks */ - uintmax_t out_part; /* # of partial output blocks */ - uintmax_t trunc; /* # of truncated records */ - uintmax_t swab; /* # of odd-length swab blocks */ - uintmax_t bytes; /* # of bytes written */ + size_t in_full; /* # of full input blocks */ + size_t in_part; /* # of partial input blocks */ + size_t out_full; /* # of full output blocks */ + size_t out_part; /* # of partial output blocks */ + size_t trunc; /* # of truncated records */ + size_t swab; /* # of odd-length swab blocks */ + size_t bytes; /* # of bytes written */ struct timespec start; /* start time of dd */ } STAT; |