From: David Sterba Date: Wed, 21 Sep 2016 11:36:04 +0000 (+0200) Subject: btrfs-progs: mkfs: fix reading rotational status value X-Git-Tag: upstream/4.16.1~1291 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=90e3e630c2f641f3ceca32672e8e3a8ac0ceae8a;p=platform%2Fupstream%2Fbtrfs-progs.git 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 --- diff --git a/mkfs.c b/mkfs.c index b33e368..adfc278 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,