From 57c6b7049e6c2025cb020927f5f731e9f16bb702 Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Sun, 22 Nov 2009 19:11:53 +0000 Subject: [PATCH] Make zap() work with non-gcc C++ compilers. Eliminate the intermediate name krb5int_zap_data. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23311 dc483132-0cff-0310-8789-dd5450dbe970 --- src/include/k5-int.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/include/k5-int.h b/src/include/k5-int.h index dee37dea2..dbc50e371 100644 --- a/src/include/k5-int.h +++ b/src/include/k5-int.h @@ -752,19 +752,18 @@ krb5int_hmac_iov_keyblock(const struct krb5_hash_provider *hash, krb5_error_code krb5int_pbkdf2_hmac_sha1(const krb5_data *, unsigned long, const krb5_data *, const krb5_data *); -/* Make this a function eventually? */ +/* Attempt to zero memory in a way that compilers won't optimize out. */ #ifdef _WIN32 -# define krb5int_zap_data(ptr, len) SecureZeroMemory(ptr, len) +# define zap(ptr, len) SecureZeroMemory(ptr, len) #elif defined(__GNUC__) -static inline void krb5int_zap_data(void *ptr, size_t len) +static inline void zap(void *ptr, size_t len) { memset(ptr, 0, len); asm volatile ("" : : "g" (ptr), "g" (len)); } #else -# define krb5int_zap_data(ptr, len) memset((volatile void *)ptr, 0, len) +# define zap(ptr, len) memset((void *)(volatile void *)ptr, 0, len) #endif /* WIN32 */ -#define zap(p,l) krb5int_zap_data(p,l) /* Convenience function: zap and free ptr if it is non-NULL. */ static inline void -- 2.26.2