mirror of
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
synced 2024-12-02 22:43:48 +08:00
badblocks: add error checking for command-line arguments for -b and -c
Also remove a dead assignment (the value of try is overwritten after the continue statement). Addresses-Coverity-Bug: 1297515 Addresses-Coverity-Bug: 1464573 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
parent
46fcf7087b
commit
10f9b11b76
@ -892,7 +892,6 @@ static unsigned int test_nd (int dev, blk_t last_block,
|
||||
test_ptr += got * block_size;
|
||||
currently_testing += got;
|
||||
if (got != try) {
|
||||
try = 1;
|
||||
if (recover_block == ~0U)
|
||||
recover_block = currently_testing -
|
||||
got + blocks_at_once;
|
||||
@ -1201,6 +1200,19 @@ int main (int argc, char ** argv)
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if ((block_size <= 0) || (block_size > (1 << 24)) ||
|
||||
(block_size & (block_size - 1))) {
|
||||
com_err(program_name, 0, _("Invalid block size: %d\n"),
|
||||
block_size);
|
||||
exit(1);
|
||||
}
|
||||
if ((blocks_at_once <= 0) ||
|
||||
(((unsigned long long) block_size * blocks_at_once) > 0xFFFFFFFF)) {
|
||||
com_err(program_name, 0, _("Invalid blocks_at_once: %d\n"),
|
||||
blocks_at_once);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (optind > argc - 1)
|
||||
usage();
|
||||
device_name = argv[optind++];
|
||||
|
Loading…
Reference in New Issue
Block a user