]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commit
libext2fs: fix off-by-one error in file truncation
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 8 Oct 2013 15:51:23 +0000 (11:51 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 8 Oct 2013 15:51:26 +0000 (11:51 -0400)
commit4605a35d1ef573dc166a73ed910d0ee7b02489cb
tree3073fd9bc1e4aff5f01422eae96fca9110542bf8
parent470ca046b1e682c419d50efc8d4941db1b8601d9
libext2fs: fix off-by-one error in file truncation

When told to truncate a file, ext2fs_file_set_size2() should start with
the first block past the end of the file.  The current calculation
jumps one more block ahead, with the result that it fails to hack off
the last block.  Adding blocksize-1 and dividing is sufficient to find
the last block.

Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/fileio.c