]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
make explicit_bzero/memset safe for sz=0
authorDamien Miller <djm@mindrot.org>
Fri, 14 Jul 2017 04:26:36 +0000 (14:26 +1000)
committerDamien Miller <djm@mindrot.org>
Fri, 14 Jul 2017 04:27:12 +0000 (14:27 +1000)
openbsd-compat/explicit_bzero.c

index 5078134d137a8d4f6de4f22dc4e52c24cc9a7c2d..53a003472721d4038a572a431d54f8948dff448f 100644 (file)
@@ -20,6 +20,8 @@
 void
 explicit_bzero(void *p, size_t n)
 {
+       if (n == 0)
+               return;
        (void)memset_s(p, n, 0, n);
 }
 
@@ -34,6 +36,8 @@ static void (* volatile ssh_bzero)(void *, size_t) = bzero;
 void
 explicit_bzero(void *p, size_t n)
 {
+       if (n == 0)
+               return;
        /*
         * clang -fsanitize=memory needs to intercept memset-like functions
         * to correctly detect memory initialisation. Make sure one is called