[Bug 190735] New: truncate(1) integer overflow issues with size command line arg -- diff with unit tests attached
bz-noreply at freebsd.org
bz-noreply at freebsd.org
Fri Jun 6 23:56:49 UTC 2014
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 at FreeBSD.org
Reporter: bugmeister at 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.
More information about the freebsd-bugs
mailing list