]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib/util: Overwrite talloc name in talloc_keep_secret() only if it would reveal memor...
authorPavel Filipenský <pfilipensky@samba.org>
Wed, 11 Mar 2026 16:39:48 +0000 (17:39 +0100)
committerPavel Filipensky <pfilipensky@samba.org>
Wed, 25 Mar 2026 20:10:37 +0000 (20:10 +0000)
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
lib/util/talloc_keep_secret.c

index eb5bb80ff37fc330a965909526ea7c3c5e61ee69..eb3d2588265abb2055bc49529648b577e51415ea 100644 (file)
@@ -49,6 +49,12 @@ void _talloc_keep_secret(void *ptr, const char *name)
                return;
        }
 
-       talloc_set_name_const(ptr, name);
+       /*
+        * Overwrite talloc name only if it reveals memory content.
+        * That prevents breaking talloc_get_type_abort().
+        */
+       if (talloc_get_name(ptr) == ptr) {
+               talloc_set_name_const(ptr, name);
+       }
        talloc_set_destructor(ptr, talloc_keep_secret_destructor);
 }