1538 static PyObject *
1539 py_hbac_evaluate(HbacRequest *self, PyObject *args)
1540 {
1541 PyObject *py_rules_list = NULL;
1542 PyObject *py_rule = NULL;
1543 Py_ssize_t num_rules;
1544 struct hbac_rule **rules = NULL;
1545 struct hbac_eval_req *hbac_req = NULL;
1546 enum hbac_eval_result eres;
1547 struct hbac_info *info = NULL;
1548 PyObject *ret = NULL;
1549 long i;
1550
1551 if (!PyArg_ParseTuple(args, sss_py_const_p(char, "O"), &py_rules_list)) {
when PyArg_ParseTuple() succeeds
taking False path
1552 goto fail;
1553 }
1554
1555 if (!PySequence_Check(py_rules_list)) {
when considering range: -0x80000000 <= value <= -1
taking False path
1556 PyErr_Format(PyExc_TypeError,
1557 "The parameter rules must be a sequence\n");
1558 goto fail;
1559 }
1560
1561 num_rules = PySequence_Size(py_rules_list);
1562 rules = PyMem_New(struct hbac_rule *, num_rules+1);
when considering range: -0x7fffffffffffffff <= value <= 0xfffffffffffffff
taking True path
when PyMem_Malloc() succeeds
1563 if (!rules) {
taking False path
1564 PyErr_NoMemory();
1565 goto fail;
1566 }
1567
1568 for (i=0; i < num_rules; i++) {
when considering range: -0x8000000000000000 <= value <= 0
taking False path
1569 py_rule = PySequence_GetItem(py_rules_list, i);
1570
1571 if (!PyObject_IsInstance(py_rule,
1572 (PyObject *) &pyhbac_hbacrule_type)) {
1573 PyErr_Format(PyExc_TypeError,
1574 "A rule must be of type HbacRule\n");
1575 goto fail;
1576 }
1577
1578 rules[i] = HbacRule_to_native((HbacRuleObject *) py_rule);
1579 if (!rules[i]) {
1580 /* Make sure there is at least a generic exception */
1581 if (!PyErr_Occurred()) {
1582 PyErr_Format(PyExc_IOError,
1583 "Could not convert HbacRule to native type\n");
1584 }
1585 goto fail;
1586 }
1587 }
1588 rules[num_rules] = NULL;
when treating unknown struct hbac_rule * * from src/python/pyhbac.c:1588 as non-NULL
1589
1590 hbac_req = HbacRequest_to_native(self);
1591 if (!hbac_req) {
when treating unknown struct hbac_eval_req * from src/python/pyhbac.c:1590 as non-NULL
taking False path
1592 if (!PyErr_Occurred()) {
1593 PyErr_Format(PyExc_IOError,
1594 "Could not convert HbacRequest to native type\n");
1595 }
1596 goto fail;
1597 }
1598
1599 Py_XDECREF(self->rule_name);
when treating unknown struct PyObject * from src/python/pyhbac.c:1599 as non-NULL
taking False path
when treating unknown struct PyObject * from src/python/pyhbac.c:1599 as non-NULL
when considering value == (Py_ssize_t)0 from src/python/pyhbac.c:1599
taking False path
when treating unknown struct PyObject * from src/python/pyhbac.c:1599 as non-NULL
when treating unknown struct _typeobject * from src/python/pyhbac.c:1599 as non-NULL
calling unknown void (*destructor) (struct PyObject *) from src/python/pyhbac.c:1599
1600 self->rule_name = NULL;
1601
1602 eres = hbac_evaluate(rules, hbac_req, &info);
1603 switch (eres) {
when following default
1604 case HBAC_EVAL_ALLOW:
1605 self->rule_name = sss_python_unicode_from_string(info->rule_name);
1606 if (!self->rule_name) {
1607 PyErr_NoMemory();
1608 goto fail;
1609 }
1610 /* FALLTHROUGH */
1611 case HBAC_EVAL_DENY:
1612 ret = PyInt_FromLong(eres);
1613 break;
1614 case HBAC_EVAL_ERROR:
1615 set_hbac_exception(PyExc_HbacError, info);
1616 goto fail;
1617 case HBAC_EVAL_OOM:
1618 PyErr_NoMemory();
1619 goto fail;
1620 }
1621
1622 free_hbac_eval_req(hbac_req);
1623 free_hbac_rule_list(rules);
1624 hbac_free_info(info);
1625 return ret;
1626
1627 fail:
1628 hbac_free_info(info);
1629 free_hbac_eval_req(hbac_req);
1630 free_hbac_rule_list(rules);
1631 return NULL;
1632 }
returning (PyObject*)NULL without setting an exception
found 3 similar trace(s) to this