memzero.h: Move memzero() and strzero() to their own header
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>
This commit is contained in:
committed by
Iker Pedrosa
parent
093fb605f9
commit
6b11077f09
@@ -85,6 +85,7 @@ libshadow_la_SOURCES = \
|
||||
mail.c \
|
||||
mempcpy.c \
|
||||
mempcpy.h \
|
||||
memzero.h \
|
||||
motd.c \
|
||||
myname.c \
|
||||
nss.c \
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "alloc.h"
|
||||
#include "memzero.h"
|
||||
#include "nscd.h"
|
||||
#include "sssd.h"
|
||||
#ifdef WITH_TCB
|
||||
|
||||
@@ -47,20 +47,6 @@
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef HAVE_MEMSET_EXPLICIT
|
||||
# define memzero(ptr, size) memset_explicit((ptr), 0, (size))
|
||||
#elif defined HAVE_EXPLICIT_BZERO /* !HAVE_MEMSET_S */
|
||||
# define memzero(ptr, size) explicit_bzero((ptr), (size))
|
||||
#else /* !HAVE_MEMSET_S && HAVE_EXPLICIT_BZERO */
|
||||
static inline void memzero(void *ptr, size_t size)
|
||||
{
|
||||
ptr = memset(ptr, '\0', size);
|
||||
__asm__ __volatile__ ("" : : "r"(ptr) : "memory");
|
||||
}
|
||||
#endif /* !HAVE_MEMSET_S && !HAVE_EXPLICIT_BZERO */
|
||||
|
||||
#define strzero(s) memzero(s, strlen(s)) /* warning: evaluates twice */
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
/*
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
#include "defines.h"
|
||||
#include "faillog.h"
|
||||
#include "failure.h"
|
||||
#include "memzero.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
|
||||
#define YEAR (365L*DAY)
|
||||
/*
|
||||
* failure - make failure entry
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#ident "$Id$"
|
||||
|
||||
#include "alloc.h"
|
||||
#include "memzero.h"
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include "groupio.h"
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "getdef.h"
|
||||
#include "shadowlog.h"
|
||||
#include <sys/resource.h>
|
||||
#include "memzero.h"
|
||||
#ifndef LIMITS_FILE
|
||||
#define LIMITS_FILE "/etc/limits"
|
||||
#endif
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <time.h>
|
||||
#include "defines.h"
|
||||
#include <lastlog.h>
|
||||
#include "memzero.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "alloc.h"
|
||||
#include "memzero.h"
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include "getdef.h"
|
||||
|
||||
33
lib/memzero.h
Normal file
33
lib/memzero.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023, Christian Göttsche <cgzones@googlemail.com>
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SHADOW_INCLUDE_LIBMISC_MEMZERO_H_
|
||||
#define SHADOW_INCLUDE_LIBMISC_MEMZERO_H_
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
|
||||
#ifdef HAVE_MEMSET_EXPLICIT
|
||||
# define memzero(ptr, size) memset_explicit((ptr), 0, (size))
|
||||
#elif defined HAVE_EXPLICIT_BZERO /* !HAVE_MEMSET_S */
|
||||
# define memzero(ptr, size) explicit_bzero((ptr), (size))
|
||||
#else /* !HAVE_MEMSET_S && HAVE_EXPLICIT_BZERO */
|
||||
static inline void memzero(void *ptr, size_t size)
|
||||
{
|
||||
ptr = memset(ptr, '\0', size);
|
||||
__asm__ __volatile__ ("" : : "r"(ptr) : "memory");
|
||||
}
|
||||
#endif /* !HAVE_MEMSET_S && !HAVE_EXPLICIT_BZERO */
|
||||
|
||||
#define strzero(s) memzero(s, strlen(s)) /* warning: evaluates twice */
|
||||
|
||||
|
||||
#endif // include guard
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "alloc.h"
|
||||
#include "memzero.h"
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include "getdef.h"
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <unistd.h>
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include "memzero.h"
|
||||
#include "pwauth.h"
|
||||
#include "getdef.h"
|
||||
#ifdef SKEY
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "alloc.h"
|
||||
#include "defines.h"
|
||||
#include "memzero.h"
|
||||
#include "prototypes.h"
|
||||
#include "pwio.h"
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "defines.h"
|
||||
#include "commonio.h"
|
||||
#include "getdef.h"
|
||||
#include "memzero.h"
|
||||
#include "sgroupio.h"
|
||||
|
||||
/*@null@*/ /*@only@*/struct sgrp *__sgr_dup (const struct sgrp *sgent)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "alloc.h"
|
||||
#include "memzero.h"
|
||||
#include "shadowio.h"
|
||||
|
||||
/*@null@*/ /*@only@*/struct spwd *__spw_dup (const struct spwd *spent)
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "alloc.h"
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include "memzero.h"
|
||||
#include "pwio.h"
|
||||
#include "shadowio.h"
|
||||
#include "shadowlog.h"
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <assert.h>
|
||||
#include "defines.h"
|
||||
#include "faillog.h"
|
||||
#include "memzero.h"
|
||||
#include "prototypes.h"
|
||||
/*@-exitarg@*/
|
||||
#include "exitcodes.h"
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "alloc.h"
|
||||
#include "defines.h"
|
||||
#include "groupio.h"
|
||||
#include "memzero.h"
|
||||
#include "nscd.h"
|
||||
#include "sssd.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "defines.h"
|
||||
#include "getdef.h"
|
||||
#include "groupio.h"
|
||||
#include "memzero.h"
|
||||
#include "nscd.h"
|
||||
#include "sssd.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "defines.h"
|
||||
#include "prototypes.h"
|
||||
#include "getdef.h"
|
||||
#include "memzero.h"
|
||||
/*@-exitarg@*/
|
||||
#include "exitcodes.h"
|
||||
#include "shadowlog.h"
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "faillog.h"
|
||||
#include "failure.h"
|
||||
#include "getdef.h"
|
||||
#include "memzero.h"
|
||||
#include "prototypes.h"
|
||||
#include "pwauth.h"
|
||||
/*@-exitarg@*/
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "alloc.h"
|
||||
#include "defines.h"
|
||||
#include "getdef.h"
|
||||
#include "memzero.h"
|
||||
#include "nscd.h"
|
||||
#include "sssd.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include "defines.h"
|
||||
#include "getdef.h"
|
||||
#include "memzero.h"
|
||||
#include "prototypes.h"
|
||||
#include "pwauth.h"
|
||||
/*@-exitarg@*/
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "faillog.h"
|
||||
#include "getdef.h"
|
||||
#include "groupio.h"
|
||||
#include "memzero.h"
|
||||
#include "nscd.h"
|
||||
#include "sssd.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "faillog.h"
|
||||
#include "getdef.h"
|
||||
#include "groupio.h"
|
||||
#include "memzero.h"
|
||||
#include "nscd.h"
|
||||
#include "sssd.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
Reference in New Issue
Block a user