From b07f014face2e2aa0abf8a3266fd716152cd0cd4 Mon Sep 17 00:00:00 2001 From: Kazuya Mio Date: Thu, 18 Nov 2010 21:51:25 +0000 Subject: e4defrag: fix segfault when e4defrag races with unlink/truncate If a file gets deleted or truncated while e4defrag is trying to operate on it, it's possible for it seg fault. Addresses-Red-Hat-Bugzilla: #641926 Reported-by: Michal Piotrowski Signed-off-by: Kazuya Mio Signed-off-by: "Theodore Ts'o" --- misc/e4defrag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'misc/e4defrag.c') diff --git a/misc/e4defrag.c b/misc/e4defrag.c index e795987c..9008bc27 100644 --- a/misc/e4defrag.c +++ b/misc/e4defrag.c @@ -942,7 +942,7 @@ static int get_file_extents(int fd, struct fiemap_extent_list **ext_list_head) fiemap_buf->fm_start = pos; memset(ext_buf, 0, ext_buf_size); ret = ioctl(fd, FS_IOC_FIEMAP, fiemap_buf); - if (ret < 0) + if (ret < 0 || fiemap_buf->fm_mapped_extents == 0) goto out; for (i = 0; i < fiemap_buf->fm_mapped_extents; i++) { ext_list = NULL; -- cgit v1.2.3