]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
debugfs: abort reading a file on failure when dumping out a file
authorTheodore Ts'o <tytso@mit.edu>
Fri, 23 May 2025 17:22:00 +0000 (13:22 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 23 May 2025 17:22:00 +0000 (13:22 -0400)
If ext2fs_file_read() fails --- perhaps due to a corrupted file
system, or an I/O error --- avoid looping forever in dump_file().

This issue was pointed out in [1] by Quentin Kaiser but the commit
description was too confusing and specific to the user's particular
situation.

[1] https://github.com/tytso/e2fsprogs/pull/149

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debugfs/dump.c

index 4ab7cadcb0c8c79d12ad7d36158c03378122f7b1..cc81a5086986da71e38a31f4aa3117bba67f0305 100644 (file)
@@ -122,8 +122,10 @@ static void dump_file(const char *cmdname, ext2_ino_t ino, int fd,
        }
        while (1) {
                retval = ext2fs_file_read(e2_file, buf, blocksize, &got);
-               if (retval)
+               if (retval) {
                        com_err(cmdname, retval, "while reading ext2 file");
+                       return;
+               }
                if (got == 0)
                        break;
                nbytes = write(fd, buf, got);