Blame SOURCES/cracklib-2.9.0-python-gzdicts.patch

c79d99
diff -up cracklib-2.9.0/python/_cracklib.c.gzdicts cracklib-2.9.0/python/_cracklib.c
c79d99
--- cracklib-2.9.0/python/_cracklib.c.gzdicts	2013-06-01 16:47:13.000000000 +0200
c79d99
+++ cracklib-2.9.0/python/_cracklib.c	2013-08-20 12:37:32.028611493 +0200
c79d99
@@ -23,6 +23,7 @@
c79d99
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
c79d99
  */
c79d99
 
c79d99
+#include "config.h"
c79d99
 #ifdef PYTHON_H
c79d99
 #include PYTHON_H
c79d99
 #else
c79d99
@@ -72,9 +73,8 @@ static char _cracklib_FascistCheck_doc [
c79d99
 static PyObject *
c79d99
 _cracklib_FascistCheck(PyObject *self, PyObject *args, PyObject *kwargs)
c79d99
 {
c79d99
-    char *candidate, *dict;
c79d99
-    char *defaultdict = NULL;
c79d99
-    const char *result;
c79d99
+    char *candidate;
c79d99
+    const char *result, *dict;
c79d99
     struct stat st;
c79d99
     char *keywords[] = {"pw", "dictpath", NULL};
c79d99
     char *dictfile;
c79d99
@@ -103,44 +103,35 @@ _cracklib_FascistCheck(PyObject *self, P
c79d99
                             "second argument was not an absolute path!");
c79d99
             return NULL;
c79d99
         }
c79d99
-        dictfile = malloc(strlen(dict) + sizeof(DICT_SUFFIX));
c79d99
-        if (dictfile == NULL)
c79d99
-        {
c79d99
-            PyErr_SetFromErrnoWithFilename(PyExc_OSError, dict);
c79d99
-            return NULL;
c79d99
-        }
c79d99
-        sprintf(dictfile, "%s" DICT_SUFFIX, dict);
c79d99
-        if (lstat(dictfile, &st) == -1)
c79d99
-        {
c79d99
-            PyErr_SetFromErrnoWithFilename(PyExc_OSError, dictfile);
c79d99
-            free(dictfile);
c79d99
-            return NULL;
c79d99
-        }
c79d99
-        free(dictfile);
c79d99
     } else
c79d99
     {
c79d99
-        defaultdict = strdup(GetDefaultCracklibDict());
c79d99
-        if (errno == ENOMEM) {
c79d99
-            PyErr_SetFromErrno(PyExc_OSError);
c79d99
-            return NULL;
c79d99
-        }
c79d99
-        dictfile = malloc(strlen(defaultdict) + sizeof(DICT_SUFFIX));
c79d99
-        if (dictfile == NULL)
c79d99
-        {
c79d99
-            PyErr_SetFromErrnoWithFilename(PyExc_OSError, defaultdict);
c79d99
-            free(defaultdict);
c79d99
-            return NULL;
c79d99
-        }
c79d99
-        sprintf(dictfile, "%s" DICT_SUFFIX, defaultdict);
c79d99
+        /* No need to strdup() anything as this is a constant value */
c79d99
+        dict = GetDefaultCracklibDict();
c79d99
+    }
c79d99
+
c79d99
+    dictfile = malloc(strlen(dict) + sizeof(DICT_SUFFIX) + 3);
c79d99
+    if (dictfile == NULL)
c79d99
+    {
c79d99
+        PyErr_SetFromErrnoWithFilename(PyExc_OSError, dict);
c79d99
+        return NULL;
c79d99
+    }
c79d99
+    sprintf(dictfile, "%s" DICT_SUFFIX, dict);
c79d99
+    if (lstat(dictfile, &st) == -1)
c79d99
+    {
c79d99
+#ifdef HAVE_ZLIB_H
c79d99
+        sprintf(dictfile, "%s" DICT_SUFFIX ".gz", dict);
c79d99
         if (lstat(dictfile, &st) == -1)
c79d99
         {
c79d99
+            sprintf(dictfile, "%s" DICT_SUFFIX, dict);
c79d99
+#endif
c79d99
             PyErr_SetFromErrnoWithFilename(PyExc_OSError, dictfile);
c79d99
-            free(defaultdict);
c79d99
             free(dictfile);
c79d99
             return NULL;
c79d99
+#ifdef HAVE_ZLIB_H
c79d99
         }
c79d99
-        free(dictfile);
c79d99
+#endif
c79d99
     }
c79d99
+    free(dictfile);
c79d99
 
c79d99
 	setlocale(LC_ALL, "");
c79d99
 #ifdef ENABLE_NLS
c79d99
@@ -148,14 +139,9 @@ _cracklib_FascistCheck(PyObject *self, P
c79d99
 #endif
c79d99
 
c79d99
     LOCK();
c79d99
-    result = FascistCheck(candidate, dict ? dict : defaultdict);
c79d99
+    result = FascistCheck(candidate, dict);
c79d99
     UNLOCK();
c79d99
 
c79d99
-    if (defaultdict != NULL)
c79d99
-    {
c79d99
-        free(defaultdict);
c79d99
-    }
c79d99
-
c79d99
     if (result != NULL)
c79d99
     {
c79d99
     	PyErr_SetString(PyExc_ValueError, result);