From owner-freebsd-bugs@FreeBSD.ORG Fri Jun 6 23:56:49 2014 Return-Path: Delivered-To: freebsd-bugs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A2DA8387 for ; Fri, 6 Jun 2014 23:56:49 +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 714002E35 for ; Fri, 6 Jun 2014 23:56:49 +0000 (UTC) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.14.8/8.14.8) with ESMTP id s56Nunsn017157 for ; Sat, 7 Jun 2014 00:56:49 +0100 (BST) (envelope-from bz-noreply@freebsd.org) From: bz-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 190735] New: truncate(1) integer overflow issues with size command line arg -- diff with unit tests attached Date: Fri, 06 Jun 2014 23:56:49 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new 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: Needs Triage X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: 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: Fri, 06 Jun 2014 23:56:49 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=190735 Bug ID: 190735 Summary: truncate(1) integer overflow issues with size command line arg -- diff with unit tests attached Product: Base System Version: 10.0-RELEASE Hardware: Any OS: Any Status: Needs Triage Severity: Affects Some People Priority: --- Component: bin Assignee: freebsd-bugs@FreeBSD.org Reporter: bugmeister@ba23.org Created attachment 143473 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=143473&action=edit Diff that fixes bug. And adds new unit tests. When you use the FreeBSD 8.4 /usr/bin/truncate, things work as expected. - get the binary from Freebsd 8.4 # tar xvf FreeBSD-8.4-RELEASE-amd64-livefs.iso usr/bin/truncate x usr/bin/truncate - fail gracefully if the size is too large for int64_t # ./usr/bin/truncate -s8388608t afile truncate: invalid size argument `8388608t' - using a size suffix to shrink a file # ./usr/bin/truncate -s16t afile # ./usr/bin/truncate -s-15t afile # ls -lh afile -rw-r--r-- 1 root wheel 1.0T Jun 6 19:44 afile With the FreeBSD 10.0 /usr/bin/truncate, we get unexpected behavior: - when the size is too large for int64_t, we expect an error, not a zero size file # /usr/bin/truncate -s8388608t afile # ls -l afile -rw-r--r-- 1 root wheel 0 Jun 6 19:47 afile - using a size suffix to shrink a file is no longer supported # /usr/bin/truncate -s16t afile # /usr/bin/truncate -s-15t afile truncate: invalid size argument `-15t' I think this is the change that caused this regression: http://svnweb.freebsd.org/base?view=revision&revision=204654 I have attached a diff that attempts to fix this issue. And also adds tests using the newer kyua format. -- You are receiving this mail because: You are the assignee for the bug.