]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli: avoid work in security token debug no-op
authorVolker Lendecke <vl@samba.org>
Mon, 14 Oct 2024 11:29:21 +0000 (13:29 +0200)
committerDouglas Bagnall <dbagnall@samba.org>
Thu, 27 Feb 2025 00:02:38 +0000 (00:02 +0000)
When the debug level is too low to print, we don't need to allocate
the strings.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15737

Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
Pair-programmed-with: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>

libcli/security/security_token.c

index 0218eed1722492248c30ff1c16fb64195a07e260..a79f5925ea2f92890ee2266932f8d9694bb3c1ea 100644 (file)
@@ -80,17 +80,22 @@ struct security_token *security_token_duplicate(TALLOC_CTX *mem_ctx, const struc
 ****************************************************************************/
 void security_token_debug(int dbg_class, int dbg_lev, const struct security_token *token)
 {
-       TALLOC_CTX *frame = talloc_stackframe();
+       TALLOC_CTX *frame = NULL;
        char *sids = NULL;
        char *privs = NULL;
        uint32_t i;
 
+       if (!CHECK_DEBUGLVLC(dbg_class, dbg_lev)) {
+               return;
+       }
+
        if (!token) {
                DEBUGC(dbg_class, dbg_lev, ("Security token: (NULL)\n"));
-               TALLOC_FREE(frame);
                return;
        }
 
+       frame = talloc_stackframe();
+
        sids = talloc_asprintf(frame,
                               "Security token SIDs (%" PRIu32 "):\n",
                               token->num_sids);