diff options
author | Keith Mok <kmok@cyngn.com> | 2016-02-16 09:46:04 -0800 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2016-02-20 09:38:33 -0800 |
commit | 515ea005fd1860a04ee37973aba352d3f3ee6954 (patch) | |
tree | 2439f832c55017a4b252a6ab89cffadc5e0d0677 /fs_mgr | |
parent | 6fe2b6e587fddd252b62fc0670364b19a4d41c54 (diff) | |
download | system_core-515ea005fd1860a04ee37973aba352d3f3ee6954.zip system_core-515ea005fd1860a04ee37973aba352d3f3ee6954.tar.gz system_core-515ea005fd1860a04ee37973aba352d3f3ee6954.tar.bz2 |
fs_mgr: BLKGETSIZE causes memory corruption
BLKGETSIZE return unsigned long sector size,
but unsigned long is of 8 bytes in 64 bits system.
Passing an integar value will causes stack corruption.
Use BLKGETSIZE64 instead.
Change-Id: If2bf44673f5ab3436f79f0af3252990d56748f5c
Diffstat (limited to 'fs_mgr')
-rw-r--r-- | fs_mgr/fs_mgr_format.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fs_mgr/fs_mgr_format.c b/fs_mgr/fs_mgr_format.c index e932990..8bda19c 100644 --- a/fs_mgr/fs_mgr_format.c +++ b/fs_mgr/fs_mgr_format.c @@ -33,7 +33,7 @@ extern void reset_ext4fs_info(); static int format_ext4(char *fs_blkdev, char *fs_mnt_point, long long fs_length) { - unsigned int nr_sec; + uint64_t dev_sz; int fd, rc = 0; if ((fd = open(fs_blkdev, O_WRONLY, 0644)) < 0) { @@ -41,7 +41,7 @@ static int format_ext4(char *fs_blkdev, char *fs_mnt_point, long long fs_length) return -1; } - if ((ioctl(fd, BLKGETSIZE, &nr_sec)) == -1) { + if ((ioctl(fd, BLKGETSIZE64, &dev_sz)) == -1) { ERROR("Cannot get block device size. %s\n", strerror(errno)); close(fd); return -1; @@ -49,7 +49,7 @@ static int format_ext4(char *fs_blkdev, char *fs_mnt_point, long long fs_length) /* Format the partition using the calculated length */ reset_ext4fs_info(); - info.len = ((off64_t)nr_sec * 512); + info.len = (off64_t)dev_sz; if (fs_length > 0) { info.len = fs_length; |