From: Debian Samba Maintainers Date: Fri, 17 Apr 2026 08:02:47 +0000 (+0300) Subject: use explicit_bzero() instead of memset_explicit() X-Git-Tag: archive/raspbian/2%4.24.1+dfsg-1+rpi1^2~15 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=fcf928591534a4104cf9faf67490d6ba29aadfad;p=samba.git use explicit_bzero() instead of memset_explicit() lib/replace/replace.h header defines ZERO_STRUCT macro which uses memset_explicit() function (which is similar to memset() but can not be optimized out by the compiler). Glibc has explicit_bzero() with similar property, while memset_explicit() is implemented in lib/replace/replace.c, - this way, some binaries needlessly link to libreplace just to get rep_memset_explicit() symbol. By using explicit_bzero() instead, this endless linkage is eliminated, so we can package, for example, libldb (which uses ZERO_STRUCT) without it linking to libreplace-samba4. Unfortunately there are just insane amount of similar but non-standard functions, and upstream don't want to stay on something simple and robust in this context. Gbp-Pq: Name use-explicit_bzero-to-zero-memory.diff --- diff --git a/lib/replace/replace.h b/lib/replace/replace.h index 051583ce..4f4d7e6b 100644 --- a/lib/replace/replace.h +++ b/lib/replace/replace.h @@ -999,7 +999,10 @@ void rep_setproctitle_init(int argc, char *argv[], char *envp[]); #endif #ifndef HAVE_MEMSET_EXPLICIT -#define memset_explicit rep_memset_explicit +#include +#define memset_explicit(ptr, ch, len) \ + do { static_assert((ch)==0, "memset is called with ch!=0"); \ + explicit_bzero((ptr), (len)); } while (0) void *rep_memset_explicit(void *block, int c, size_t size); #endif