]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
memzero.h: Add MEMZERO() macro
authorAlejandro Colomar <alx@kernel.org>
Sun, 30 Jul 2023 12:32:39 +0000 (14:32 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Fri, 1 Sep 2023 07:39:23 +0000 (09:39 +0200)
It calculates the size of the array safely, via SIZEOF_ARRAY(), instead of
sizeof(), which can be dangerous.

Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/memzero.h

index cf2f70204ac2794a3157289ba2d87ab2c28a226f..99e2beca5c6ad28c12ad5dbb7e658cc6d1877cc6 100644 (file)
 #include <string.h>
 #include <strings.h>
 
+#include "sizeof.h"
+
+
+#define MEMZERO(arr)  memzero(arr, SIZEOF_ARRAY(arr))
+
 
 inline void memzero(void *ptr, size_t size);
 inline void strzero(char *s);