From c2c5c58593f7e4944fcf57d07e66baaf6a82b11d Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Fri, 22 Jul 2016 01:20:10 +0200 Subject: [PATCH] libext2fs: fix infinite loop if copying in an empty directory 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 Signed-off-by: Theodore Ts'o --- misc/create_inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/create_inode.c b/misc/create_inode.c index fd5cb21f..5122e56c 100644 --- a/misc/create_inode.c +++ b/misc/create_inode.c @@ -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) {