]> eyrie.org Git - kerberos/krb5-strength.git/commitdiff
Fix some sorting bugs in embedded CrackLib
authorRuss Allbery <eagle@eyrie.org>
Mon, 7 Nov 2016 06:23:13 +0000 (22:23 -0800)
committerRuss Allbery <eagle@eyrie.org>
Mon, 7 Nov 2016 06:23:13 +0000 (22:23 -0800)
Patch the mkdict and packer in the embedded copy of CrackLib to force
C locale when sorting (avoiding a corrupted dictionary) and warn and
skip out-of-order words rather than creating a corrupted dictionary.
Patch from Mark Sirota.

NEWS
cracklib/HISTORY
cracklib/mkdict
cracklib/packer.c

diff --git a/NEWS b/NEWS
index fca40de7aa01efb189dca2d3ccadf9b240909665..73cb8932663626b9c8b169f6f7c1c399f7c5051d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,11 @@ krb5-strength 3.1 (unreleased)
     doesn't apply since all the GECOS manipulation code was removed from
     the embedded CrackLib in this package.)
 
+    Patch the mkdict and packer in the embedded copy of CrackLib to force
+    C locale when sorting (avoiding a corrupted dictionary) and warn and
+    skip out-of-order words rather than creating a corrupted dictionary.
+    Patch from Mark Sirota.
+
     Update to rra-c-util 6.2:
 
     * Use calloc in preference to malloc wherever appropriate.
index 3a9621914f64873a10c5ab888058ce92df8537ab..a0081cc75056b8be7eca6e723ca406400262f666 100644 (file)
@@ -23,6 +23,8 @@ following modifications have been made:
  * Close the wfp file handle on PWClose if it's open.
  * Applied various patches from distributions for security vulnerabilities.
  * Changed the type of some variables to size_t to avoid truncation.
+ * Forced locale in mkdict to avoid problems with non-C-locale sort.
+ * Added a warning to packer if processing out-of-order words.
 
 See the leading comments in each source file for a more detailed timeline
 and list of changes.
index 9a61d37fc185b3e9c6070539297ea536fcc26d23..50050eb1b2719ad3575d46e2b4428647f5fb03e0 100755 (executable)
@@ -8,9 +8,17 @@
 # and upwards.
 ###
 
+# Modified as part of the krb5-strength project as follows:
+#
+# 2016-11-06  Russ Allbery <eagle@eyrie.org>
+#   - Force C locale when sorting to avoid creating a corrupt dictionary.
+
 ### in case of explosion, invoke "sort" with "-T" option pointing to a lot
 ### of free space in a directory somewhere.
 
+# Force C locale, since that's what packer expects.
+LC_ALL=C; export LC_ALL
+
 SORT="sort"
 ###SORT="sort -T /tmp"
 
index e601b385c2a8ca2839c686eacac362837b7dae02..feb579806feaee715cd2be9464a240d40f739aba 100644 (file)
@@ -13,6 +13,8 @@
  *   - Add ANSI C protototypes for all functions.
  * 2010-03-14  Russ Allbery <eagle@eyrie.org>
  *   - Use unsigned long instead of int32 to avoid printf warnings.
+ * 2016-11-06  Mark Sirota <msirota@isc.upenn.edu>
+ *   - Display a warning when processing out-of-order input.
  */
 
 #include "packer.h"
@@ -23,7 +25,7 @@ main(int argc, char *argv[])
     unsigned long readed;
     unsigned long wrote;
     PWDICT *pwp;
-    char buffer[STRINGSIZE];
+    char buffer[STRINGSIZE], prev[STRINGSIZE];
 
     if (argc <= 1)
     {
@@ -38,6 +40,7 @@ main(int argc, char *argv[])
     }
 
     wrote = 0;
+    prev[0] = '\0';
 
     for (readed = 0; fgets(buffer, STRINGSIZE, stdin); /* nothing */)
     {
@@ -53,6 +56,18 @@ main(int argc, char *argv[])
            continue;
        }
 
+       /*
+        * If this happens, strcmp() in FindPW() in packlib.c will be unhappy.
+        */
+       if (strcmp(buffer, prev) < 0)
+       {
+           fprintf(stderr, "warning: input out of order: '%s' should not"
+                   " follow '%s' (line %lu), skipping\n", buffer, prev,
+                   readed);
+           continue;
+       }
+       strcpy(prev, buffer);
+
        if (PutPW(pwp, buffer))
        {
            fprintf(stderr, "error: PutPW '%s' line %luy\n", buffer, readed);