mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-18 14:20:09 +01:00
Use explicit_bzero if available.
This commit is contained in:
@@ -94,7 +94,7 @@ AC_SUBST(UUID_LIBS, $LIBS)
|
|||||||
LIBS=$saved_LIBS
|
LIBS=$saved_LIBS
|
||||||
|
|
||||||
AC_SEARCH_LIBS([clock_gettime],[rt posix4])
|
AC_SEARCH_LIBS([clock_gettime],[rt posix4])
|
||||||
AC_CHECK_FUNCS([posix_memalign clock_gettime posix_fallocate])
|
AC_CHECK_FUNCS([posix_memalign clock_gettime posix_fallocate explicit_bzero])
|
||||||
|
|
||||||
if test "x$enable_largefile" = "xno"; then
|
if test "x$enable_largefile" = "xno"; then
|
||||||
AC_MSG_ERROR([Building with --disable-largefile is not supported, it can cause data corruption.])
|
AC_MSG_ERROR([Building with --disable-largefile is not supported, it can cause data corruption.])
|
||||||
|
|||||||
@@ -124,8 +124,12 @@ int crypt_storage_encrypt(struct crypt_storage *ctx, uint64_t sector,
|
|||||||
/* Memzero helper (memset on stack can be optimized out) */
|
/* Memzero helper (memset on stack can be optimized out) */
|
||||||
static inline void crypt_backend_memzero(void *s, size_t n)
|
static inline void crypt_backend_memzero(void *s, size_t n)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_EXPLICIT_BZERO
|
||||||
|
explicit_bzero(s, n);
|
||||||
|
#else
|
||||||
volatile uint8_t *p = (volatile uint8_t *)s;
|
volatile uint8_t *p = (volatile uint8_t *)s;
|
||||||
while(n--) *p++ = 0;
|
while(n--) *p++ = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _CRYPTO_BACKEND_H */
|
#endif /* _CRYPTO_BACKEND_H */
|
||||||
|
|||||||
@@ -155,10 +155,14 @@ int crypt_parse_pbkdf(const char *s, const char **pbkdf)
|
|||||||
*/
|
*/
|
||||||
void crypt_memzero(void *s, size_t n)
|
void crypt_memzero(void *s, size_t n)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_EXPLICIT_BZERO
|
||||||
|
explicit_bzero(s, n);
|
||||||
|
#else
|
||||||
volatile uint8_t *p = (volatile uint8_t *)s;
|
volatile uint8_t *p = (volatile uint8_t *)s;
|
||||||
|
|
||||||
while(n--)
|
while(n--)
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* safe allocations */
|
/* safe allocations */
|
||||||
|
|||||||
Reference in New Issue
Block a user