From ea97af65c5194137cec7bd770b79cd601d2a92a0 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Fri, 28 May 2021 22:14:04 -0500 Subject: [PATCH] libext2fs: improve error handling in POSIX ACL conversions When encoding a POSIX ACL to the EXT4 ACL format, if an unknown tag is encountered, that entry is silently ignored. It would be better to return an error to inform the user that the ACL is incompatible. Also fix the mismatched indentation in the opposite function. Signed-off-by: Samuel Holland --- lib/ext2fs/ext_attr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c index 4f6371d..efe4d29 100644 --- a/lib/ext2fs/ext_attr.c +++ b/lib/ext2fs/ext_attr.c @@ -573,6 +573,8 @@ static errcode_t convert_posix_acl_to_disk_buffer(const void *value, size_t size e += sizeof(ext4_acl_entry); s += sizeof(ext4_acl_entry); break; + default: + return EINVAL; } } *size_out = s; @@ -626,9 +628,9 @@ static errcode_t convert_disk_buffer_to_posix_acl(const void *value, size_t size cp += sizeof(ext4_acl_entry); size -= sizeof(ext4_acl_entry); break; - default: - ext2fs_free_mem(&out); - return EINVAL; + default: + ext2fs_free_mem(&out); + return EINVAL; } entry++; } -- 1.8.3.1