]> git.ipfire.org Git - thirdparty/util-linux.git/commit
fincore: Handle large files correctly on 32 bit
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 25 Feb 2018 19:27:18 +0000 (20:27 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 26 Feb 2018 10:54:12 +0000 (11:54 +0100)
commitea62c152766ff22038630c9afdeb1df5dcc044cb
tree22322c429c1b8b33bcec32dbee675dbddd498642
parent2e20500a449955a69ea0b8381453079e8b57e9d3
fincore: Handle large files correctly on 32 bit

If a file is larger than 4 GB on a 32 bit system with large file
support (default), it can happen that not all pages are properly
processed. This happens due to an int truncation (off_t vs size_t).

You can reproduce this on 32 bit with these commands:

$ dd if=/dev/zero of=4gb-file seek=4294967295 count=1 bs=1
$ fincore 4gb-file
fincore: failed to do mmap: 4gb-file: Invalid argument

If a file is larger than 4 GB, the first few pages of a file won't
be properly processed. "len" will be smaller than window_size,
but the for-loop iterates "window_size" bytes, skipping some pages.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
misc-utils/fincore.c