]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs: chage ext2_off_t and ext2_off64_t to be signed types
authorTheodore Ts'o <tytso@mit.edu>
Wed, 1 Jan 2020 00:00:49 +0000 (19:00 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 1 Jan 2020 18:41:35 +0000 (13:41 -0500)
The ext2_off_t and ext2_off64_t types are used by ext2_file_lseek()
and ext2_file_llseek(), and they need to be signed so that it can be a
negative offset from the end of the file when EXT2_SEEK_END is used.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/blknum.c
lib/ext2fs/ext2fs.h
lib/ext2fs/ext_attr.c

index 31055c34c69c2d70059b6849c5aca5af0ccc7975..ec77a067b37188be04932317e69dd600f60a5d92 100644 (file)
@@ -537,6 +537,9 @@ void ext2fs_file_acl_block_set(ext2_filsys fs, struct ext2_inode *inode,
 errcode_t ext2fs_inode_size_set(ext2_filsys fs, struct ext2_inode *inode,
                                ext2_off64_t size)
 {
+       if (size < 0)
+               return EINVAL;
+
        /* Only regular files get to be larger than 4GB */
        if (!LINUX_S_ISREG(inode->i_mode) && (size >> 32))
                return EXT2_ET_FILE_TOO_BIG;
index ca5e3321a54e49131a9e37c721ca6743bde3aca2..cbf0c6f4db68c9bd10f3ea648f324012fd43a044 100644 (file)
@@ -77,8 +77,8 @@ typedef __u32 __bitwise               ext2_ino_t;
 typedef __u32 __bitwise                blk_t;
 typedef __u64 __bitwise                blk64_t;
 typedef __u32 __bitwise                dgrp_t;
-typedef __u32 __bitwise                ext2_off_t;
-typedef __u64 __bitwise                ext2_off64_t;
+typedef __s32 __bitwise                ext2_off_t;
+typedef __s64 __bitwise                ext2_off64_t;
 typedef __s64 __bitwise                e2_blkcnt_t;
 typedef __u32 __bitwise                ext2_dirhash_t;
 
index affc1a8fc07edd21a0984767c3cfc2987f7c71e1..871319a5a8a4324e718fcbc96183873b9c0e1aa3 100644 (file)
@@ -924,8 +924,8 @@ static errcode_t read_xattrs_from_buffer(struct ext2_xattr_handle *handle,
                            !(ea_inode->i_flags & EXT4_EA_INODE_FL) ||
                            ea_inode->i_links_count == 0)
                                err = EXT2_ET_EA_INODE_CORRUPTED;
-                       else if (ext2fs_file_get_size(ea_file) !=
-                           entry->e_value_size)
+                       else if ((__u64) ext2fs_file_get_size(ea_file) !=
+                                entry->e_value_size)
                                err = EXT2_ET_EA_BAD_VALUE_SIZE;
                        else
                                err = ext2fs_file_read(ea_file, x->value,