aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2019-12-31 19:00:49 -0500
committerTheodore Ts'o <tytso@mit.edu>2020-01-01 13:41:35 -0500
commit1d4074f3ed3da1fde3b6bbbfa744ab92823886df (patch)
tree5d090f65d7888aeb03f8eacd94f85cbcedbe6555
parent193cf9be4bed56e47797baa1774cc81d7d76e242 (diff)
downloade2fsprogs-1d4074f3ed3da1fde3b6bbbfa744ab92823886df.tar.gz
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 <tytso@mit.edu>
-rw-r--r--lib/ext2fs/blknum.c3
-rw-r--r--lib/ext2fs/ext2fs.h4
-rw-r--r--lib/ext2fs/ext_attr.c4
3 files changed, 7 insertions, 4 deletions
diff --git a/lib/ext2fs/blknum.c b/lib/ext2fs/blknum.c
index 31055c34c..ec77a067b 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 ca5e3321a..cbf0c6f4d 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 affc1a8fc..871319a5a 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,