1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-03 01:18:10 +03:00
samba-mirror/lib/cmdline
Michael Tokarev 712117155e replace direct calls to memset_s() with commonly used macros
samba provides macros for zeroing various structures in memory,
and all code uses them instead of relying on memset_s().
However, a few places use memset_s() directly.  Replace these
usages with macros for consistency and to be able to replace
memset_s() easier.

A few notes.

Commit 03a50d8f7d "lib:util: Check memset_s() error
code in talloc_keep_secret_destructor()" (Aug-2022) added a check
for error return from memset_s().  This is the only place in whole
codebase which bothers about doing this.  But I've difficult time
figuring out the intention.  Was there a real case when this code
path is actually executed?

Commit 7658c9bf0a "lib:crypto: Remove redundant array
zeroing" (Nov-2023) removed the OTHER line from the two lines used
to zero memory in here.  Initially the code used both memset_s()
*and* ZERO_ARRAY_LEN(), the former has been removed.  This change
removes the other - memset_s(), reintroducing ZERO_ARRAY_LEN().
Here however, it's probably better to use BURN_PTR instead of
ZERO_ARRAY - in this place and a few lines above.

Commit 8dddea2ced "lib:talloc: Use memset_s() to avoid
the call gets optimized out" (Feb-2024) is a recent commit which
introduces memset_s().  However, it does not seem like it makes
any difference whatsoever for a testsuite, or that it actually
needs to clean up the memory to begin with.

We've quite an assortment of all this memory zeroing stuff.  Also
it is repeated in replace.h and memory.h (two sets in these files
are different but has big intersection).  I'd say, to fix this mess,
things from replace.h should be removed in favour of memory.h, and
necessary includes added, but this is for the next time.  We also
have lots of direct usages of memset_s() in heimdal code.

Cc: Joseph Sutton <josephsutton@catalyst.net.nz>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2025-01-02 17:01:30 +00:00
..
tests cmdline: test_cmdline tests more burning 2024-07-03 01:35:31 +00:00
closefrom_except.c lib: Move closefrom_except*() to a separate file 2021-09-21 01:12:12 +00:00
closefrom_except.h lib: Move closefrom_except*() to a separate file 2021-09-21 01:12:12 +00:00
cmdline_private.h lib:cmdline: Fix code spelling 2023-12-21 20:21:34 +00:00
cmdline_s3.c cmdline: Make -P work in clustered mode 2021-11-17 18:29:09 +00:00
cmdline_s4.c lib:cmdline: Load network interfaces in _samba_cmdline_load_config_s4() 2024-08-04 00:32:39 +00:00
cmdline.c replace direct calls to memset_s() with commonly used macros 2025-01-02 17:01:30 +00:00
cmdline.h lib/cmdline: Return if the commandline was redacted in samba_cmdline_burn() 2023-07-21 05:23:32 +00:00
wscript lib:cmdline: Load network interfaces in _samba_cmdline_load_config_s4() 2024-08-04 00:32:39 +00:00