From owner-freebsd-bugs@FreeBSD.ORG Sat Jun 7 22:37:01 2014 Return-Path: Delivered-To: freebsd-bugs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DABABCAE for ; Sat, 7 Jun 2014 22:37:01 +0000 (UTC) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C17182969 for ; Sat, 7 Jun 2014 22:37:01 +0000 (UTC) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.14.8/8.14.8) with ESMTP id s57Mb1UR062911 for ; Sat, 7 Jun 2014 23:37:01 +0100 (BST) (envelope-from bz-noreply@freebsd.org) From: bz-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 190735] truncate(1) integer overflow issues with size command line arg -- diff with unit tests attached Date: Sat, 07 Jun 2014 22:37:02 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 10.0-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: bugmeister@ba23.org X-Bugzilla-Status: In Discussion X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Jun 2014 22:37:01 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=190735 --- Comment #2 from Kirk Russell --- Jilles, thanks for looking! I have removed the new undocumented -D option and stopped using the macro from . I like your idea of using ktrace but I will want to research that idea before including that in a diff -- I will remove this ktrace/-D stuff from the patch -- I hope that is okay. I will attach a new patch to this bug, with the new changes. You can clarify your comment the expectations of off_t being OFF_MAX? My idea is the truncate utility needs to indicate an error if OFF_MAX < size < OFF_MIN. The function humanize_number() will allow numbers out-of-range for off_t and we should tell the user as soon as possible about this conversion problem. What the OS does with an large off_t passed to truncate() is the OS's business. For example, it is possible to create a huge sparse file in ZFS. I am not sure what this sparse file is useful for, but it is nice to see that ls -h works. # printf "%d\n" 0x7fffffffffffffff 9223372036854775807 # /usr/obj/usr/src/usr.bin/truncate/truncate -s 9223372036854775807 sparse.txt # ls -l sparse.txt -rw-r--r-- 1 root wheel 9223372036854775807 Jun 7 18:30 sparse.txt # ls -lh sparse.txt -rw-r--r-- 1 root wheel 8.0E Jun 7 18:33 sparse.txt -- You are receiving this mail because: You are the assignee for the bug.