]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e4defrag: defensively check results of sysconf(_SC_PAGESIZE)
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 12 Dec 2013 18:08:45 +0000 (13:08 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 12 Dec 2013 18:08:49 +0000 (13:08 -0500)
sysconf(_SC_PAGESIZE) will probably never return an error, but just in
case it does, we shouldn't pass what looks like a huge number to
sync_file_range() and posix_fadvise().

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/e4defrag.c

index b6e2e319524320b94ea5642713478bbf993d73bf..07d56d9f50aae5450f28339ee5ad1ca5894f23eb 100644 (file)
@@ -473,6 +473,9 @@ static int defrag_fadvise(int fd, struct move_extent defrag_data,
        unsigned int    i;
        loff_t  offset;
 
+       if (pagesize < 1)
+               return -1;
+
        offset = (loff_t)defrag_data.orig_start * block_size;
        offset = (offset / pagesize) * pagesize;