From 64ab4012398343e474e61fc4214dccb37f9ee994 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Sun, 30 Jul 2023 14:32:39 +0200 Subject: [PATCH] memzero.h: Add MEMZERO() macro MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It calculates the size of the array safely, via SIZEOF_ARRAY(), instead of sizeof(), which can be dangerous. Cc: Christian Göttsche Cc: Serge Hallyn Cc: Iker Pedrosa Signed-off-by: Alejandro Colomar --- lib/memzero.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/memzero.h b/lib/memzero.h index cf2f70204..99e2beca5 100644 --- a/lib/memzero.h +++ b/lib/memzero.h @@ -15,6 +15,11 @@ #include #include +#include "sizeof.h" + + +#define MEMZERO(arr) memzero(arr, SIZEOF_ARRAY(arr)) + inline void memzero(void *ptr, size_t size); inline void strzero(char *s); -- 2.47.3