mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-28 00:52:17 +00:00
btrfs-progs: mkfs: fix reading rotational status value
ASAN reports that we're reading beyond the bounds, and is right. The variable is too short to store a nonempty string for atoi. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
d75e061bcd
commit
90e3e630c2
4
mkfs.c
4
mkfs.c
@ -1193,13 +1193,13 @@ static int is_ssd(const char *file)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (read(fd, &rotational, sizeof(char)) < sizeof(char)) {
|
||||
if (read(fd, &rotational, 1) < 1) {
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
return !atoi((const char *)&rotational);
|
||||
return rotational == '0';
|
||||
}
|
||||
|
||||
static int _cmp_device_by_id(void *priv, struct list_head *a,
|
||||
|
Loading…
Reference in New Issue
Block a user