]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Avoid allocating a register in zap() assembly 889/head
authorAndreas Schneider <asn@samba.org>
Thu, 3 Jan 2019 16:19:32 +0000 (17:19 +0100)
committerGreg Hudson <ghudson@mit.edu>
Mon, 14 Jan 2019 16:14:49 +0000 (11:14 -0500)
See https://bugs.llvm.org/show_bug.cgi?id=15495

Also add explicit_bzero() (glibc, FreeBSD) and explicit_memset()
(NetBSD) as alternatives.

[ghudson@mit.edu: added explicit_bzero() and explicit_memset()]

src/configure.in
src/include/k5-platform.h

index 61ef738dc4e7e860a472221d0aa03c20a9a69713..54cf107f84ef28c42644364b9ba7e3bca5432f98 100644 (file)
@@ -421,7 +421,7 @@ AC_PROG_LEX
 AC_C_CONST
 AC_HEADER_DIRENT
 AC_FUNC_STRERROR_R
-AC_CHECK_FUNCS(strdup setvbuf seteuid setresuid setreuid setegid setresgid setregid setsid flock fchmod chmod strptime geteuid setenv unsetenv getenv gmtime_r localtime_r bswap16 bswap64 mkstemp getusershell access getcwd srand48 srand srandom stat strchr strerror timegm)
+AC_CHECK_FUNCS(strdup setvbuf seteuid setresuid setreuid setegid setresgid setregid setsid flock fchmod chmod strptime geteuid setenv unsetenv getenv gmtime_r localtime_r bswap16 bswap64 mkstemp getusershell access getcwd srand48 srand srandom stat strchr strerror timegm explicit_bzero explicit_memset)
 
 AC_CHECK_FUNC(mkstemp,
 [MKSTEMP_ST_OBJ=
index 997b655e1e2bb882e71f416042c4c2c5919a251a..1fcd68e8c0ebe6ef3cdc75247cbb90f31fa03ed3 100644 (file)
@@ -1023,6 +1023,10 @@ static inline void zap(void *ptr, size_t len)
     if (len > 0)
         memset_s(ptr, len, 0, len);
 }
+#elif defined(HAVE_EXPLICIT_BZERO)
+# define zap(ptr, len) explicit_bzero(ptr, len)
+#elif defined(HAVE_EXPLICIT_MEMSET)
+# define zap(ptr, len) explicit_memset(ptr, 0, len)
 #elif defined(__GNUC__) || defined(__clang__)
 /*
  * Use an asm statement which declares a memory clobber to force the memset to
@@ -1032,7 +1036,7 @@ static inline void zap(void *ptr, size_t len)
 {
     if (len > 0)
         memset(ptr, 0, len);
-    __asm__ __volatile__("" : : "r" (ptr) : "memory");
+    __asm__ __volatile__("" : : "g" (ptr) : "memory");
 }
 #else
 /*