Whamcloud - gitweb
libext2fs: improve error handling in POSIX ACL conversions
authorSamuel Holland <samuel@sholland.org>
Sat, 29 May 2021 03:14:04 +0000 (22:14 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 30 Jul 2021 17:38:14 +0000 (13:38 -0400)
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>
lib/ext2fs/ext_attr.c

index 4f6371d..efe4d29 100644 (file)
@@ -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++;
        }