replace: Use memset_s for ZERO_* macros
authorAndreas Schneider <asn@samba.org>
Mon, 3 Dec 2018 14:31:30 +0000 (15:31 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 20 Dec 2018 11:16:39 +0000 (12:16 +0100)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/replace/replace.h

index 36058ec35e96ee9cf22d81edc9534a9ee65966b4..76898f013f8e9af338f9edc00fb4ad55bc006d02 100644 (file)
@@ -808,23 +808,27 @@ typedef unsigned long long ptrdiff_t ;
 /**
  * Zero a structure.
  */
-#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
+#define ZERO_STRUCT(x) memset_s((char *)&(x), sizeof(x), 0, sizeof(x))
 
 /**
  * Zero a structure given a pointer to the structure.
  */
-#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)
+#define ZERO_STRUCTP(x) do { \
+       if ((x) != NULL) { \
+               memset_s((char *)(x), sizeof(*(x)), 0, sizeof(*(x))); \
+       } \
+} while(0)
 
 /**
  * Zero a structure given a pointer to the structure - no zero check
  */
-#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x)))
+#define ZERO_STRUCTPN(x) memset_s((char *)(x), sizeof(*(x)), 0, sizeof(*(x)))
 
 /**
  * Zero an array - note that sizeof(array) must work - ie. it must not be a
  * pointer
  */
-#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x))
+#define ZERO_ARRAY(x) memset_s((char *)(x), sizeof(x), 0, sizeof(x))
 
 /**
  * Work out how many elements there are in a static array.