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

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