Skip to content

Commit

Permalink
debugfs: fix endless loop when calling rdump on fs where extended att…
Browse files Browse the repository at this point in the history
…ribute value conflicts with key.

When recursively dumping the content of an ext2 filesystem where
extended attribute value conflicts with key using "rdump / /tmp/out ",
debugfs get's in an endless loop.

This is due to the fact that we only break out of the while(1) loop if
the 'got' value is 0, which never happens when an error is encountered.

The applied fix mimics what happens when retval is non-zero and returns.

This can be tested with an existing test sample
(tests/f_ea_value_crash/image.gz).
  • Loading branch information
qkaiser committed Jun 14, 2023
1 parent e76886f commit bbe107f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion debugfs/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bbe107f

Please sign in to comment.