From: Jeffrey Altman Date: Thu, 15 Jul 2004 07:38:09 +0000 (+0000) Subject: * k5-int.h: define for WIN32 the macro krb5int_zap_data to X-Git-Tag: krb5-1.4-beta1~207 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=492e321bff67f150817dac59d9633bd17a07ccd7;p=krb5.git * k5-int.h: define for WIN32 the macro krb5int_zap_data to utilize the Win32 API SecureZeroMemory which is guaranteed by Microsoft not to be optimized out by the compiler. Both memset and ZeroMemory will be optimized out by the compiler when possible. ticket: new git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16600 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/include/ChangeLog b/src/include/ChangeLog index 9bceef3ad..75eb6c6a6 100644 --- a/src/include/ChangeLog +++ b/src/include/ChangeLog @@ -1,3 +1,11 @@ +2004-07-14 Jeffrey Altman + + * k5-int.h: define for WIN32 the macro krb5int_zap_data to + utilize the Win32 API SecureZeroMemory which is guaranteed + by Microsoft not to be optimized out by the compiler. + Both memset and ZeroMemory will be optimized out by the + compiler when possible. + 2004-07-13 Ken Raeburn * k5-platform.h (k5_call_init_function) [DELAY_INITIALIZER] @@ -24,6 +32,7 @@ * fake-addrinfo.h (in6addr_any): If we need to define a static copy, rename it with a macro first. +>>>>>>> 1.444 2004-07-09 Ken Raeburn * k5-thread.h: Test HAVE_PTHREAD instead of HAVE_PTHREAD_H. diff --git a/src/include/k5-int.h b/src/include/k5-int.h index fe7a5a113..d668f1ec9 100644 --- a/src/include/k5-int.h +++ b/src/include/k5-int.h @@ -672,13 +672,17 @@ krb5_error_code krb5int_pbkdf2_hmac_sha1 (const krb5_data *, unsigned long, const krb5_data *); /* Make this a function eventually? */ -#define krb5int_zap_data(ptr, len) memset((volatile void *)ptr, 0, len) -#if defined(__GNUC__) && defined(__GLIBC__) +#ifdef WIN32 +# define krb5int_zap_data(ptr, len) SecureZeroMemory(ptr, 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 +# undef memset +# endif +#endif /* WIN32 */ #define zap(p,l) krb5int_zap_data(p,l) /* A definition of init_state for DES based encryption systems.