]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e4defrag: Check error return of sysconf()
authorEric Sandeen <sandeen@redhat.com>
Fri, 16 Sep 2011 20:49:39 +0000 (15:49 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 16 Sep 2011 23:55:55 +0000 (19:55 -0400)
In theory sysconf() can fail, so check for an error return.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/e4defrag.c

index eea30571ee3767277b7069dace0e8fc95c1d9e5b..cdf4ffb0cec21b6b8ca1a26267d57ce5987458b5 100644 (file)
@@ -399,13 +399,16 @@ static int calc_entry_counts(const char *file EXT2FS_ATTR((unused)),
 static int page_in_core(int fd, struct move_extent defrag_data,
                        unsigned char **vec, unsigned int *page_num)
 {
-       long    pagesize = sysconf(_SC_PAGESIZE);
+       long    pagesize;
        void    *page = NULL;
        loff_t  offset, end_offset, length;
 
        if (vec == NULL || *vec != NULL)
                return -1;
 
+       pagesize = sysconf(_SC_PAGESIZE);
+       if (pagesize < 0)
+               return -1;
        /* In mmap, offset should be a multiple of the page size */
        offset = (loff_t)defrag_data.orig_start * block_size;
        length = (loff_t)defrag_data.len * block_size;