Whamcloud - gitweb
resize2fs, libext2fs: fix bugs in sparse_super2 support
[tools/e2fsprogs.git] / lib / ext2fs / read_bb_file.c
index 25454a8..8d1ad1a 100644 (file)
@@ -9,6 +9,7 @@
  * %End-Header%
  */
 
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
 #if HAVE_UNISTD_H
@@ -38,7 +39,7 @@ errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f,
                                               void *priv_data))
 {
        errcode_t       retval;
-       blk_t           blockno;
+       blk64_t         blockno;
        int             count;
        char            buf[128];
 
@@ -54,9 +55,12 @@ errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f,
        while (!feof (f)) {
                if (fgets(buf, sizeof(buf), f) == NULL)
                        break;
-               count = sscanf(buf, "%u", &blockno);
+               count = sscanf(buf, "%llu", &blockno);
                if (count <= 0)
                        continue;
+               /* Badblocks isn't going to be updated for 64bit */
+               if (blockno >> 32)
+                       return EOVERFLOW;
                if (fs &&
                    ((blockno < fs->super->s_first_data_block) ||
                     (blockno >= ext2fs_blocks_count(fs->super)))) {