]> granicus.if.org Git - cracklib/commitdiff
add fix for Python string distance calculation by Pascal Muetschard
authorJan Dittberner <jan@dittberner.info>
Thu, 25 Sep 2014 16:48:36 +0000 (16:48 +0000)
committerJan Dittberner <jan@dittberner.info>
Thu, 25 Sep 2014 16:48:36 +0000 (16:48 +0000)
git-svn-id: file:///tmp/cracklib-svn/trunk@230 4175fe1e-86d5-4fdc-8e6a-506fab9d8533

cracklib/NEWS
cracklib/python/cracklib.py

index 6f953995295a89016d90c5750e6b9069fdf4e5af..07218c1aae628cbc27dd19e71fe8826378a0b20d 100644 (file)
@@ -1,11 +1,12 @@
 v2.9.2 support build of python support outside of source tree (Michał Górny)
+       fix bug in Python string distance calculation (Pascal Muetschard)
 v2.9.1 added updated config.sub/config.guess in autogen
 v2.9.0 add new FascistCheckUser function from Enrico Scholz, bumped minor version for library
 v2.8.22 error return instead of exit if dictionary can't be opened (Nalin Dahyabhai)
 v2.8.21 export prototype for FascistLook (Nalin Dahyabhai)
 v2.8.20 include python/test_cracklib.py in release tarball (Jan Dittberner)
         rename python/_cracklibmodule.c to python/_cracklib.c to support Python 3.3 (Jan Dittberner)
-               patch from Ivosh (iraisr) for uninitialized buffer issue with small dictionaries.
+        patch from Ivosh (iraisr) for uninitialized buffer issue with small dictionaries.
 v2.8.19 drop autogenerated files from SVN (Mike Frysinger)
         add words from "The Top 500 Worst Passwords of All Time" <http://www.whatsmypass.com/the-top-500-worst-passwords-of-all-time> to dicts/cracklib-small (patch by Fabian Greffrath)
         include sys/stat.h in python/_cracklibmodule.c (Mike Frysinger)
@@ -20,7 +21,7 @@ v2.8.17 fixed compilation on interix systems
         fix segmentation fault in Python extension (Peter Palfrader)
         add -Wall to AM_CFLAGS to discover possible programming errors (Jan Dittberner)
         updated Wei Liu (zh_CN) translation (Leah Liu)
-               fixed NLS support in python module compilation (Mike Frysinger)
+        fixed NLS support in python module compilation (Mike Frysinger)
 v2.8.16 update licensing information in Python extension (Jan Dittberner)
         make translations work in Python extension (Jan Dittberner)
         fix Python extension compilation warning (Jan Dittberner)
index aee9a0d19387023a309eccffd7d33ff960ce3708..9de7e892e1fb8098d10ccc3a275bc67797bb3873 100644 (file)
@@ -57,12 +57,12 @@ def distdifferent(old, new, i, j):
         cval = 0
     else:
         cval = old[i - 1]
-    
-    if j == 0 or len(new) <= i:
+
+    if j == 0 or len(new) <= j:
         dval = 0
     else:
         dval = new[j - 1]
-    
+
     return cval != dval
 
 
@@ -70,7 +70,7 @@ def distcalculate(distances, old, new, i, j):
     """Calculates the distance between two strings.
     """
     tmp = 0
-    
+
     if distances[i][j] != -1:
         return distances[i][j]
 
@@ -93,7 +93,7 @@ def distance(old, new):
     distances = [ [] for i in range(oldlength + 1) ]
     for i in range(oldlength + 1):
         distances[i] = [ -1 for j in range(newlength + 1) ]
+
     for i in range(oldlength + 1):
         distances[i][0] = i
     for j in range(newlength + 1):
@@ -114,7 +114,7 @@ def similar(old, new):
     """
     if distance(old, new) >= DIFF_OK:
         return 0
-    
+
     if len(new) >= (len(old) * 2):
         return 0
 
@@ -164,12 +164,12 @@ def simple(new):
         size = size - digits
     elif digits < (DIG_CREDIT * -1):
         return 1
+
     if UP_CREDIT >= 0:
         size = size - uppers
     elif uppers < (UP_CREDIT * -1):
         return 1
+
     if LOW_CREDIT >= 0:
         size = size - lowers
     elif lowers < (LOW_CREDIT * -1):
@@ -182,7 +182,7 @@ def simple(new):
 
     if len(new) < size:
         return 1
-        
+
     return 0
 
 
@@ -193,7 +193,7 @@ def VeryFascistCheck(new, old = None, dictpath = None):
     if old != None:
         if new == old:
             raise ValueError("is the same as the old one")
-                
+
         oldmono = old.lower()
         newmono = new.lower()
         wrapped = old + old
@@ -204,7 +204,7 @@ def VeryFascistCheck(new, old = None, dictpath = None):
             raise ValueError("is rotated")
         if similar(oldmono, newmono):
             raise ValueError("is too similar to the old one")
-    
+
     if dictpath == None:
         FascistCheck(new)
     else: