From: Ken Raeburn Date: Mon, 21 May 2007 21:44:40 +0000 (+0000) Subject: Simplify UNIX krb5int_zap_data a little. Omit volatile cast, just call memset, X-Git-Tag: krb5-1.7-alpha1~1107 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=659539f21538312c0871ff42e31b826c3f99b72f;p=krb5.git Simplify UNIX krb5int_zap_data a little. Omit volatile cast, just call memset, but for gcc, use a volatile asm afterwards to make the memory appear to be referenced and deter optimizations that would remove the memset. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19553 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/include/k5-int.h b/src/include/k5-int.h index 93a0b1abb..0b01026ec 100644 --- a/src/include/k5-int.h +++ b/src/include/k5-int.h @@ -684,18 +684,14 @@ krb5_error_code krb5int_pbkdf2_hmac_sha1 (const krb5_data *, unsigned long, /* Make this a function eventually? */ #ifdef _WIN32 # define krb5int_zap_data(ptr, len) SecureZeroMemory(ptr, len) -#elif defined(__palmos__) && !defined(__GNUC__) -/* CodeWarrior 8.3 complains about passing a pointer to volatile in to - memset. On the other hand, we probably want it for gcc. */ -# define krb5int_zap_data(ptr, len) memset(ptr, 0, len) +#elif defined(__GNUC__) +static inline void krb5int_zap_data(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) -# if defined(__GNUC__) && defined(__GLIBC__) -/* GNU libc generates multiple bogus initialization warnings if we - pass memset a volatile pointer. The compiler should do well enough - with memset even without GNU libc's attempt at optimization. */ -# undef memset -# endif #endif /* WIN32 */ #define zap(p,l) krb5int_zap_data(p,l)