]> eyrie.org Git - kerberos/krb5-strength.git/commitdiff
Wipe password copies before freeing them
authorRuss Allbery <eagle@eyrie.org>
Thu, 6 Mar 2014 19:45:24 +0000 (11:45 -0800)
committerRuss Allbery <eagle@eyrie.org>
Thu, 6 Mar 2014 19:45:24 +0000 (11:45 -0800)
We make a copy of the user's password in several places when doing
checks for passwords based on the user's principal.  Be sure to
wipe those copies with memset before freeing them.

plugin/principal.c

index 5dfe55d82c23e3a78b6d0fefe57ca235b4b7287b..fd19cd489ffa466cc1474e8c47db40b090d5c4c5 100644 (file)
@@ -8,7 +8,7 @@
  * Developed by Derrick Brashear and Ken Hornstein of Sine Nomine Associates,
  *     on behalf of Stanford University
  * Extensive modifications by Russ Allbery <eagle@eyrie.org>
- * Copyright 2006, 2007, 2009, 2012, 2013
+ * Copyright 2006, 2007, 2009, 2012, 2013, 2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
  * See LICENSE for licensing terms.
@@ -56,6 +56,7 @@ check_component(krb5_context ctx, const char *component, const char *password)
             copy[j] = c;
         }
         if (strcasecmp(copy, password) == 0) {
+            memset(copy, 0, strlen(copy));
             free(copy);
             return strength_error_generic(ctx, ERROR_USERNAME);
         }
@@ -158,6 +159,7 @@ strength_check_principal(krb5_context ctx, krb5_pwqual_moddata data UNUSED,
         if (i != 0) {
             code = check_component(ctx, copy + i, password);
             if (code != 0) {
+                memset(copy, 0, strlen(copy));
                 free(copy);
                 return code;
             }
@@ -174,6 +176,7 @@ strength_check_principal(krb5_context ctx, krb5_pwqual_moddata data UNUSED,
         /* Check the current component. */
         code = check_component(ctx, start, password);
         if (code != 0) {
+            memset(copy, 0, strlen(copy));
             free(copy);
             return code;
         }
@@ -184,6 +187,7 @@ strength_check_principal(krb5_context ctx, krb5_pwqual_moddata data UNUSED,
     } while (i < length);
 
     /* Password does not appear to be based on the principal. */
+    memset(copy, 0, strlen(copy));
     free(copy);
     return 0;
 }