[Bug 224845] Change return type to size_t.

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Tue Jan 9 17:17:49 UTC 2018


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224845

Mitchell Horne <mhorne063 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mhorne063 at gmail.com

--- Comment #1 from Mitchell Horne <mhorne063 at gmail.com> ---
(In reply to Bulat from comment #0)

What appears different between the FreeBSD and OpenBSD implementations of dd is
that FreeBSD supports the 't' (tera) and 'p' (peta) file size options on the
command line. So on systems where size_t is implemented as 32 bits, some
information would be lost if the user were to input a large file size. By 
using uintmax_t, it (almost) guarantees that the entirety of the user's input
size is captured, as uintmax_t is at least 64 bits wide. In the case that the
largest possible file size is smaller than the user's input, SIZE_MAX is used
instead.

An example: The user inputs "1t" as a file size on a system where size_t is
32-bits wide. The value 1 is taken and bit shifted 40 times (1TB = 2^40 bytes),
and the 32 bit value of size_t is filled with only zeros, resulting in a 0 byte
output file or an error.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list