]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
AOSP: Fix file offset overflow issue when file's size > 4G
authorChen Lin Z <lin.z.chen@intel.com>
Mon, 10 Dec 2018 07:31:40 +0000 (15:31 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 5 Mar 2019 17:56:45 +0000 (12:56 -0500)
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.

[ This was also fixed upstream via 1eec7413677e: "create_inode: fix
  copying large files".  This commit is just to clean up
  whitespace/formatting issues. -- tytso ]

Signed-off-by: Chen Lin Z <lin.z.chen@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
From AOSP commit: 999dd56f2586fadec7bfe846b8cb52c5e528248f

misc/create_inode.c

index aa865a41f7e8f07aebf712c1eac1a8f30771d380..b288935d79f4f288638ac5d54b27a6824a2fbe61 100644 (file)
@@ -439,7 +439,7 @@ static errcode_t copy_file_chunk(ext2_filsys fs, int fd, ext2_file_t e2_file,
                                continue;
                        }
                        err = ext2fs_file_llseek(e2_file, off + bpos,
-                                               EXT2_SEEK_SET, NULL);
+                                                EXT2_SEEK_SET, NULL);
                        if (err)
                                goto fail;
                        while (blen > 0) {
@@ -481,7 +481,8 @@ static errcode_t try_lseek_copy(ext2_filsys fs, int fd, struct stat *statbuf,
                        return EXT2_ET_UNIMPLEMENTED;
 
                data_blk = data & ~(off_t)(fs->blocksize - 1);
-               hole_blk = (hole + (off_t)(fs->blocksize - 1)) & ~(off_t)(fs->blocksize - 1);
+               hole_blk = ((hole + (off_t)(fs->blocksize - 1)) &
+                           ~(off_t)(fs->blocksize - 1));
                err = copy_file_chunk(fs, fd, e2_file, data_blk, hole_blk, buf,
                                      zerobuf);
                if (err)