From: Theodore Ts'o Date: Wed, 1 Jan 2020 00:00:49 +0000 (-0500) Subject: libext2fs: chage ext2_off_t and ext2_off64_t to be signed types X-Git-Tag: v1.45.5~12 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=1d4074f3ed3da1fde3b6bbbfa744ab92823886df;p=tools%2Fe2fsprogs.git libext2fs: chage ext2_off_t and ext2_off64_t to be signed types 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 --- diff --git a/lib/ext2fs/blknum.c b/lib/ext2fs/blknum.c index 31055c3..ec77a06 100644 --- a/lib/ext2fs/blknum.c +++ b/lib/ext2fs/blknum.c @@ -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; diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index ca5e332..cbf0c6f 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -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; diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c index affc1a8..871319a 100644 --- a/lib/ext2fs/ext_attr.c +++ b/lib/ext2fs/ext_attr.c @@ -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,