void *priv_data))
{
errcode_t retval;
- blk_t blockno;
+ blk64_t blockno;
int count;
char buf[128];
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)))) {
unsigned int);
int open_flag;
long sysval;
+ blk64_t inblk;
setbuf(stdout, NULL);
setbuf(stderr, NULL);
first_block = parse_uint(argv[optind], _("first block"));
} else first_block = 0;
if (first_block >= last_block) {
- com_err (program_name, 0, _("invalid starting block (%lu): must be less than %lu"),
- (unsigned long) first_block, (unsigned long) last_block);
+ com_err (program_name, 0, _("invalid starting block (%llu): must be less than %llu"),
+ first_block, last_block);
exit (1);
}
+ /* ext2 badblocks file can't handle large values */
+ if (last_block >> 32) {
+ com_err(program_name, EOVERFLOW,
+ _("invalid end block (%llu): must be 32-bit value"),
+ last_block);
+ exit(1);
+ }
if (w_flag)
check_mount(device_name);
if (in) {
for(;;) {
- switch(fscanf (in, "%u\n", &next_bad)) {
+ switch (fscanf(in, "%llu\n", &inblk)) {
case 0:
com_err (program_name, 0, "input file - bad format");
exit (1);
case EOF:
break;
default:
+ if (inblk >> 32) {
+ com_err(program_name,
+ EOVERFLOW,
+ _("while adding to in-memory bad block list"));
+ exit(1);
+ }
+ next_bad = inblk;
errcode = ext2fs_badblocks_list_add(bb_list,next_bad);
if (errcode) {
com_err (program_name, errcode, _("while adding to in-memory bad block list"));