]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli: Simplify get_sec_mask_str()
authorVolker Lendecke <vl@samba.org>
Wed, 6 Oct 2021 08:33:50 +0000 (10:33 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 8 Oct 2021 19:28:32 +0000 (19:28 +0000)
Use talloc_asprintf_addbuf()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
libcli/security/display_sec.c

index 506ecf6d89d49813a6b30d1b5a8af81f3a84d039..d75b89071c34793685e9914eea76725ea0477e94 100644 (file)
@@ -31,86 +31,38 @@ char *get_sec_mask_str(TALLOC_CTX *ctx, uint32_t type)
 {
        char *typestr = talloc_strdup(ctx, "");
 
-       if (!typestr) {
-               return NULL;
-       }
-
        if (type & SEC_GENERIC_ALL) {
-               typestr = talloc_asprintf_append(typestr,
-                               "Generic all access ");
-               if (!typestr) {
-                       return NULL;
-               }
+               talloc_asprintf_addbuf(&typestr, "Generic all access ");
        }
        if (type & SEC_GENERIC_EXECUTE) {
-               typestr = talloc_asprintf_append(typestr,
-                               "Generic execute access");
-               if (!typestr) {
-                       return NULL;
-               }
+               talloc_asprintf_addbuf(&typestr, "Generic execute access");
        }
        if (type & SEC_GENERIC_WRITE) {
-               typestr = talloc_asprintf_append(typestr,
-                               "Generic write access ");
-               if (!typestr) {
-                       return NULL;
-               }
+               talloc_asprintf_addbuf(&typestr, "Generic write access ");
        }
        if (type & SEC_GENERIC_READ) {
-               typestr = talloc_asprintf_append(typestr,
-                               "Generic read access ");
-               if (!typestr) {
-                       return NULL;
-               }
+               talloc_asprintf_addbuf(&typestr, "Generic read access ");
        }
        if (type & SEC_FLAG_MAXIMUM_ALLOWED) {
-               typestr = talloc_asprintf_append(typestr,
-                               "MAXIMUM_ALLOWED_ACCESS ");
-               if (!typestr) {
-                       return NULL;
-               }
+               talloc_asprintf_addbuf(&typestr, "MAXIMUM_ALLOWED_ACCESS ");
        }
        if (type & SEC_FLAG_SYSTEM_SECURITY) {
-               typestr = talloc_asprintf_append(typestr,
-                               "SYSTEM_SECURITY_ACCESS ");
-               if (!typestr) {
-                       return NULL;
-               }
+               talloc_asprintf_addbuf(&typestr, "SYSTEM_SECURITY_ACCESS ");
        }
        if (type & SEC_STD_SYNCHRONIZE) {
-               typestr = talloc_asprintf_append(typestr,
-                               "SYNCHRONIZE_ACCESS ");
-               if (!typestr) {
-                       return NULL;
-               }
+               talloc_asprintf_addbuf(&typestr, "SYNCHRONIZE_ACCESS ");
        }
        if (type & SEC_STD_WRITE_OWNER) {
-               typestr = talloc_asprintf_append(typestr,
-                               "WRITE_OWNER_ACCESS ");
-               if (!typestr) {
-                       return NULL;
-               }
+               talloc_asprintf_addbuf(&typestr, "WRITE_OWNER_ACCESS ");
        }
        if (type & SEC_STD_WRITE_DAC) {
-               typestr = talloc_asprintf_append(typestr,
-                               "WRITE_DAC_ACCESS ");
-               if (!typestr) {
-                       return NULL;
-               }
+               talloc_asprintf_addbuf(&typestr, "WRITE_DAC_ACCESS ");
        }
        if (type & SEC_STD_READ_CONTROL) {
-               typestr = talloc_asprintf_append(typestr,
-                               "READ_CONTROL_ACCESS ");
-               if (!typestr) {
-                       return NULL;
-               }
+               talloc_asprintf_addbuf(&typestr, "READ_CONTROL_ACCESS ");
        }
        if (type & SEC_STD_DELETE) {
-               typestr = talloc_asprintf_append(typestr,
-                               "DELETE_ACCESS ");
-               if (!typestr) {
-                       return NULL;
-               }
+               talloc_asprintf_addbuf(&typestr, "DELETE_ACCESS ");
        }
 
        printf("\t\tSpecific bits: 0x%lx\n", (unsigned long)type&SEC_MASK_SPECIFIC);