s3-passdb: Return assigned number of hours and not MAX_HOURS_LEN
authorAmitay Isaacs <amitay@gmail.com>
Thu, 25 Aug 2011 06:50:34 +0000 (16:50 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 26 Aug 2011 00:06:33 +0000 (10:06 +1000)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
source3/passdb/py_passdb.c

index cc59b64608e958375de2d509ea47a13db757c5ed..c4129c35e35e8048643088c7ea631d0fe5552228 100644 (file)
@@ -774,19 +774,20 @@ static PyObject *py_samu_get_hours(PyObject *obj, void *closure)
        struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
        PyObject *py_hours;
        const char *hours;
-       int i;
+       int hours_len, i;
 
        hours = (const char *)pdb_get_hours(sam_acct);
        if(! hours) {
                Py_RETURN_NONE;
        }
 
-       if ((py_hours = PyList_New(MAX_HOURS_LEN)) == NULL) {
+       hours_len = pdb_get_hours_len(sam_acct);
+       if ((py_hours = PyList_New(hours_len)) == NULL) {
                PyErr_NoMemory();
                return NULL;
        }
 
-       for (i=0; i<MAX_HOURS_LEN; i++) {
+       for (i=0; i<hours_len; i++) {
                PyList_SetItem(py_hours, i, PyInt_FromLong(hours[i]));
        }
        return py_hours;