diff options
author | Jan Dittberner <jan@dittberner.info> | 2014-09-25 16:48:36 +0000 |
---|---|---|
committer | Jan Dittberner <jan@dittberner.info> | 2014-09-25 16:48:36 +0000 |
commit | 93ce8f978e546b0e03a58fbdc18b7845637a84d4 (patch) | |
tree | ea064b802f14ec113966892bd2c532ec544d8a3f | |
parent | 8706f0cab1e68a25215dfccba36a5ff3ce983017 (diff) | |
download | cracklib-93ce8f978e546b0e03a58fbdc18b7845637a84d4.tar.gz |
add fix for Python string distance calculation by Pascal Muetschard
git-svn-id: file:///tmp/cracklib-svn/trunk@230 4175fe1e-86d5-4fdc-8e6a-506fab9d8533
-rw-r--r-- | cracklib/NEWS | 5 | ||||
-rw-r--r-- | cracklib/python/cracklib.py | 22 |
2 files changed, 14 insertions, 13 deletions
diff --git a/cracklib/NEWS b/cracklib/NEWS index 6f95399..07218c1 100644 --- a/cracklib/NEWS +++ b/cracklib/NEWS @@ -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) diff --git a/cracklib/python/cracklib.py b/cracklib/python/cracklib.py index aee9a0d..9de7e89 100644 --- a/cracklib/python/cracklib.py +++ b/cracklib/python/cracklib.py @@ -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: |