]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blobdiff - e2fsck/ehandler.c
fuse2fs: fix fsname option in some cases
[thirdparty/e2fsprogs.git] / e2fsck / ehandler.c
index 10216db23a843d74b154e81916e35d63be7225cd..71ca301ca5fe8777d51ce1e2bbcc58484e05bdbd 100644 (file)
@@ -6,6 +6,7 @@
  * under the terms of the GNU Public License.
  */
 
+#include "config.h"
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
@@ -57,9 +58,14 @@ static errcode_t e2fsck_handle_read_error(io_channel channel,
                printf(_("Error reading block %lu (%s).  "), block,
                       error_message(error));
        preenhalt(ctx);
+
+       /* Don't rewrite a block past the end of the FS. */
+       if (block >= ext2fs_blocks_count(fs->super))
+               return 0;
+
        if (ask(ctx, _("Ignore error"), 1)) {
                if (ask(ctx, _("Force rewrite"), 1))
-                       io_channel_write_blk64(channel, block, 1, data);
+                       io_channel_write_blk64(channel, block, count, data);
                return 0;
        }