]> eyrie.org Git - kerberos/krb5-strength.git/blobdiff - tools/heimdal-strength.c
Add dependabot configuration
[kerberos/krb5-strength.git] / tools / heimdal-strength.c
index 00e5aaa3b8c650ffda46c79297d6e79ad5f6f0b1..e44b7a45305e4b1f000643b395e559ec7c05b508 100644 (file)
@@ -6,11 +6,12 @@
  * interface.  It uses a krb5.conf parameter to determine the location of its
  * dictionary.
  *
- * Written by Russ Allbery <rra@stanford.edu>
+ * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2020 Russ Allbery <eagle@eyrie.org>
  * Copyright 2009, 2013
  *     The Board of Trustees of the Leland Stanford Junior University
  *
- * See LICENSE for licensing terms.
+ * SPDX-License-Identifier: MIT
  */
 
 #include <config.h>
@@ -21,8 +22,8 @@
 
 #include <plugin/internal.h>
 #include <util/macros.h>
-#include <util/messages.h>
 #include <util/messages-krb5.h>
+#include <util/messages.h>
 #include <util/xmalloc.h>
 
 
@@ -35,8 +36,9 @@ static void
 read_key(const char *key, char *buffer, size_t length)
 {
     char *p;
+    int size = (length < INT_MAX) ? (int) length : INT_MAX;
 
-    if (fgets(buffer, length, stdin) == NULL)
+    if (fgets(buffer, size, stdin) == NULL)
         sysdie("Cannot read %s", key);
     if (strlen(buffer) < 1 || buffer[strlen(buffer) - 1] != '\n')
         die("Malformed or too long %s line", key);
@@ -70,7 +72,7 @@ check_password(krb5_context ctx, krb5_pwqual_moddata data)
         sysdie("Cannot read end of entry");
     if (strcmp(end, "end\n") != 0)
         die("Malformed end line");
-    code = pwcheck_check(ctx, data, password, principal);
+    code = strength_check(ctx, data, principal, password);
     if (code == 0)
         printf("APPROVED\n");
     else {
@@ -103,7 +105,7 @@ main(int argc, char *argv[] UNUSED)
     code = krb5_init_context(&ctx);
     if (code != 0)
         die_krb5(ctx, code, "Cannot create Kerberos context");
-    code = pwcheck_init(ctx, NULL, &data);
+    code = strength_init(ctx, NULL, &data);
     if (code != 0)
         die_krb5(ctx, code, "Cannot initialize strength checking");
 
@@ -111,7 +113,7 @@ main(int argc, char *argv[] UNUSED)
     check_password(ctx, data);
 
     /* Close and free resources. */
-    pwcheck_close(ctx, data);
+    strength_close(ctx, data);
     krb5_free_context(ctx);
     exit(0);
 }