cracklib/cracklib-2.8.9-suffix.patch
Nalin Dahyabhai cc74371eea - improve reports of out-of-memory exceptions so that they don't include a
bogus filename
- improve reports of file-missing exceptions from the python module so that
    they give the right filename (#225858)
2007-06-20 18:39:28 +00:00

49 lines
1.7 KiB
Diff

--- cracklib-2.8.9/python/cracklibmodule.c.suffix 2005-09-26 16:42:34.000000000 -0400
+++ cracklib-2.8.9/python/cracklibmodule.c 2007-06-20 14:16:52.000000000 -0400
@@ -19,11 +19,13 @@ static pthread_mutex_t cracklib_mutex =
#define UNLOCK()
#endif
+#define DICT_SUFFIX ".pwd"
+
static PyObject *
cracklib_FascistCheck(PyObject *self, PyObject *args, PyObject *kwargs)
{
int i;
- char *candidate, *dict;
+ char *candidate, *dict, *dictfile;
const char *result;
struct stat st;
char *keywords[] = {"pw", "dictpath", NULL};
@@ -52,17 +54,26 @@ cracklib_FascistCheck(PyObject *self, Py
"second argument was not an absolute path!");
return NULL;
}
- if (lstat(dict, &st) == -1)
+ dictfile = malloc(strlen(dict) + sizeof(DICT_SUFFIX));
+ if (dictfile == NULL)
+ {
+ PyErr_SetFromErrno(PyExc_MemoryError);
+ return NULL;
+ }
+ sprintf(dictfile, "%s" DICT_SUFFIX, dict);
+ if (lstat(dictfile, &st) == -1)
{
- PyErr_SetFromErrnoWithFilename(PyExc_OSError, dict);
+ PyErr_SetFromErrnoWithFilename(PyExc_OSError, dictfile);
+ free(dictfile);
return NULL;
}
+ free(dictfile);
} else
{
- if (lstat(DEFAULT_CRACKLIB_DICT ".pwd", &st) == -1)
+ if (lstat(DEFAULT_CRACKLIB_DICT DICT_SUFFIX, &st) == -1)
{
PyErr_SetFromErrnoWithFilename(PyExc_OSError,
- DEFAULT_CRACKLIB_DICT);
+ DEFAULT_CRACKLIB_DICT DICT_SUFFIX);
return NULL;
}
}