lib: Use talloc_asprintf_addbuf() in print_ace_flags()
authorVolker Lendecke <vl@samba.org>
Thu, 12 Jan 2023 10:51:50 +0000 (11:51 +0100)
committerRalph Boehme <slow@samba.org>
Thu, 12 Jan 2023 15:38:30 +0000 (15:38 +0000)
Simplifies code.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/lib/util_sd.c

index a4288a46f3d982f0f55ac99f9442ce3314cca21a..02e4648e2075370e840727da37ac2b46ac4a8f02 100644 (file)
@@ -241,45 +241,25 @@ static void print_ace_flags(FILE *f, uint8_t flags)
 {
        char *str = talloc_strdup(NULL, "");
 
-       if (!str) {
-               goto out;
-       }
-
        if (flags & SEC_ACE_FLAG_OBJECT_INHERIT) {
-               str = talloc_asprintf(str, "%s%s",
-                               str, "OI|");
-               if (!str) {
-                       goto out;
-               }
+               talloc_asprintf_addbuf(&str, "OI|");
        }
        if (flags & SEC_ACE_FLAG_CONTAINER_INHERIT) {
-               str = talloc_asprintf(str, "%s%s",
-                               str, "CI|");
-               if (!str) {
-                       goto out;
-               }
+               talloc_asprintf_addbuf(&str, "CI|");
        }
        if (flags & SEC_ACE_FLAG_NO_PROPAGATE_INHERIT) {
-               str = talloc_asprintf(str, "%s%s",
-                               str, "NP|");
-               if (!str) {
-                       goto out;
-               }
+               talloc_asprintf_addbuf(&str, "NP|");
        }
        if (flags & SEC_ACE_FLAG_INHERIT_ONLY) {
-               str = talloc_asprintf(str, "%s%s",
-                               str, "IO|");
-               if (!str) {
-                       goto out;
-               }
+               talloc_asprintf_addbuf(&str, "IO|");
        }
        if (flags & SEC_ACE_FLAG_INHERITED_ACE) {
-               str = talloc_asprintf(str, "%s%s",
-                               str, "I|");
-               if (!str) {
-                       goto out;
-               }
+               talloc_asprintf_addbuf(&str, "I|");
        }
+       if (str == NULL) {
+               goto out;
+       }
+
        /* Ignore define SEC_ACE_FLAG_SUCCESSFUL_ACCESS ( 0x40 )
           and SEC_ACE_FLAG_FAILED_ACCESS ( 0x80 ) as they're
           audit ace flags. */