File: use-bzero-instead-of-memset_s.diff

package info (click to toggle)
samba 2%3A4.23.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 188,292 kB
  • sloc: ansic: 2,006,966; python: 272,597; sh: 72,188; xml: 51,608; perl: 36,088; makefile: 6,353; yacc: 5,320; exp: 1,582; lex: 1,504; cpp: 1,224; awk: 589; java: 119; csh: 58; pascal: 54; sed: 45; asm: 30
file content (24 lines) | stat: -rw-r--r-- 1,015 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Subject: use bzero() instead of memset_s()

lib/replace/replace.h header defines ZERO_STRUCT macro
which uses memset_s() function (which is similar to
memset() but can not be optimized out by the compiler).
Glibc has bzero() with similar property, while memset_s()
have is implemented in lib/replace/replace.c, - this way,
some binaries needlessly link with libreplace-samba4 just
to get rep_memset_s() symbol. By using bzero() instead,
this endless linkage is eliminated, so we can package,
for example, libldb (which uses ZERO_STRUCT) without it
linking to libreplace-samba4.

Note: actually using explicit_bzero() so it is not optimized
out by the compiler - this is the original goal of using
memset_s().

diff --git a/lib/replace/replace.h b/lib/replace/replace.h
index 8609d84322c..28db8d425a3 100644
--- a/lib/replace/replace.h
+++ b/lib/replace/replace.h
@@ -822 +822 @@
-#define ZERO_STRUCT(x) memset_s((char *)&(x), sizeof(x), 0, sizeof(x))
+#define ZERO_STRUCT(x) explicit_bzero((char *)&(x), sizeof(x))