summaryrefslogtreecommitdiff
path: root/mkfs.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-09-21 13:36:04 +0200
committerDavid Sterba <dsterba@suse.com>2016-09-21 13:36:04 +0200
commit90e3e630c2f641f3ceca32672e8e3a8ac0ceae8a (patch)
tree1a10ee9fa425c8ed0544fc82b047fc09866fee45 /mkfs.c
parentd75e061bcd46634cf97559ee43e889d1f21b11b5 (diff)
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>
Diffstat (limited to 'mkfs.c')
-rw-r--r--mkfs.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/mkfs.c b/mkfs.c
index b33e3688..adfc2786 100644
--- a/mkfs.c
+++ b/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,