diff options
author | Chen Lin Z <lin.z.chen@intel.com> | 2018-12-10 15:31:40 +0800 |
---|---|---|
committer | Lin Z Chen <lin.z.chen@intel.com> | 2019-01-10 01:57:52 +0000 |
commit | 999dd56f2586fadec7bfe846b8cb52c5e528248f (patch) | |
tree | d2cf0a4f18f85654fae461a885c30fbd9c0287da | |
parent | 16ba4f877ea0c32d2a491f94e092b6cf09f1b44a (diff) | |
download | android_external_e2fsprogs-999dd56f2586fadec7bfe846b8cb52c5e528248f.tar.gz android_external_e2fsprogs-999dd56f2586fadec7bfe846b8cb52c5e528248f.tar.bz2 android_external_e2fsprogs-999dd56f2586fadec7bfe846b8cb52c5e528248f.zip |
Fix file offset overflow issue when file's size > 4G
fs->blocksize is int(4 bytes), while data is off_t(8 bytes),
'data_blk = data & ~(fs->blocksize - 1)' will cause data_blk
lose high 4 bytes of data if data > 4G and it'll cause file
inconsistent when using -d option to populate ext4 image file.
Signed-off-by: Chen Lin Z <lin.z.chen@intel.com>
-rw-r--r-- | misc/create_inode.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/misc/create_inode.c b/misc/create_inode.c index 05aa6363..7b3a8ee2 100644 --- a/misc/create_inode.c +++ b/misc/create_inode.c @@ -438,8 +438,8 @@ static errcode_t copy_file_chunk(ext2_filsys fs, int fd, ext2_file_t e2_file, ptr += blen; continue; } - err = ext2fs_file_lseek(e2_file, off + bpos, - EXT2_SEEK_SET, NULL); + err = ext2fs_file_llseek(e2_file, off + bpos, + EXT2_SEEK_SET, NULL); if (err) goto fail; while (blen > 0) { @@ -480,8 +480,8 @@ static errcode_t try_lseek_copy(ext2_filsys fs, int fd, struct stat *statbuf, if (hole < 0) return EXT2_ET_UNIMPLEMENTED; - data_blk = data & ~(fs->blocksize - 1); - hole_blk = (hole + (fs->blocksize - 1)) & ~(fs->blocksize - 1); + data_blk = data & ~(off_t)(fs->blocksize - 1); + hole_blk = (hole + (fs->blocksize - 1)) & ~(off_t)(fs->blocksize - 1); err = copy_file_chunk(fs, fd, e2_file, data_blk, hole_blk, buf, zerobuf); if (err) |