From ea30eb29bac9b8ed7adca43024232069e1da0103 Mon Sep 17 00:00:00 2001
From: Samuel Holland <samuel@sholland.org>
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 <samuel@sholland.org>

diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c
index 8a7a17c..b882170 100644
--- a/lib/ext2fs/ext_attr.c
+++ b/lib/ext2fs/ext_attr.c
@@ -572,6 +572,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;
@@ -625,10 +627,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;
-			break;
+			default:
+				ext2fs_free_mem(&out);
+				return EINVAL;
 		}
 		entry++;
 	}
-- 
2.33.0

