]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs: fix infinite loop if copying in an empty directory
authorMatthias Andree <matthias.andree@gmx.de>
Thu, 21 Jul 2016 23:20:10 +0000 (01:20 +0200)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 23 Jul 2016 16:40:17 +0000 (12:40 -0400)
In m_minrootdir, on FreeBSD 9.3, try_lseek_copy() fails on an empty file
because errcode is uninitialized and the while() loop never executes,
and the errcode garbage is returned.

Initialize errcode = 0 in try_lseek_copy() to avoid a "fail" result when
there was nothing to copy.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/create_inode.c

index fd5cb21f14ba383b3eeb84ff4c4c289b2d96c5ee..5122e56cfb13d28ab381c67db3b9018f4a2d5e8c 100644 (file)
@@ -450,7 +450,7 @@ static errcode_t try_lseek_copy(ext2_filsys fs, int fd, struct stat *statbuf,
 {
        off_t data = 0, hole;
        off_t data_blk, hole_blk;
-       errcode_t err;
+       errcode_t err = 0;
 
        /* Try to use SEEK_DATA and SEEK_HOLE */
        while (data < statbuf->st_size) {