-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python/pysss_nss_idmap: check return from functions #5226
Conversation
ffc7051
to
917947b
Compare
Thanks for the update. Please see comment inline. Btw, wouldn't it make sense to include |
Yes, it makes sense. I'll change it.
It makes sense to include Line 39 in fbc7082
What do you think? |
I think you just spotted yet another one place that needs fixing: Moreover, taking into account where this macro ( |
917947b
to
362d696
Compare
Agreed. Take a look to the latest update, which contains all the aforementioned errors fixed. |
Why do we need both I still think we can have single macro (calling |
362d696
to
b60f79f
Compare
Thank you for the updated version. Please see a couple of comments inline. |
b60f79f
to
fac5f07
Compare
Change MODINITERROR macro to dereference module when PyModule_* interfaces report some type of failure.
Coverity warns that PyModule_AddIntConstant() returns operation success or failure but this value is never checked. ``` Error: CHECKED_RETURN (CWE-252): sssd-2.3.0/src/python/pysss_nss_idmap.c:587: check_return: Calling "PyModule_AddIntConstant" without checking return value (as is done elsewhere 4 out of 5 times). sssd-2.3.0/src/python/pyhbac.c:1956: example_assign: Example 1: Assigning: "ret" = return value from "PyModule_AddIntConstant(m, "HBAC_CATEGORY_ALL", 1L)". sssd-2.3.0/src/python/pyhbac.c:1957: example_checked: Example 1 (cont.): "ret" has its value checked in "ret == -1". sssd-2.3.0/src/python/pyhbac.c:1960: example_assign: Example 2: Assigning: "ret" = return value from "PyModule_AddIntConstant(m, "HBAC_RULE_ELEMENT_USERS", 1L)". sssd-2.3.0/src/python/pyhbac.c:1961: example_checked: Example 2 (cont.): "ret" has its value checked in "ret == -1". sssd-2.3.0/src/python/pyhbac.c:1972: example_assign: Example 3: Assigning: "ret" = return value from "PyModule_AddIntConstant(m, "HBAC_EVAL_DENY", HBAC_EVAL_DENY)". sssd-2.3.0/src/python/pyhbac.c:1973: example_checked: Example 3 (cont.): "ret" has its value checked in "ret == -1". sssd-2.3.0/src/python/pyhbac.c:1982: example_assign: Example 4: Assigning: "ret" = return value from "PyModule_AddIntConstant(m, "HBAC_ERROR_NOT_IMPLEMENTED", HBAC_ERROR_NOT_IMPLEMENTED)". sssd-2.3.0/src/python/pyhbac.c:1983: example_checked: Example 4 (cont.): "ret" has its value checked in "ret == -1". # 585| PyModule_AddIntConstant(module, "ID_NOT_SPECIFIED", # 586| SSS_ID_TYPE_NOT_SPECIFIED); # 587|-> PyModule_AddIntConstant(module, "ID_USER", SSS_ID_TYPE_UID); # 588| PyModule_AddIntConstant(module, "ID_GROUP", SSS_ID_TYPE_GID); # 589| PyModule_AddIntConstant(module, "ID_BOTH", SSS_ID_TYPE_BOTH); ``` Moreover, even though coverity doesn't indicate it the same happens with PyModule_AddStringConstant().
If PyModule* actions fail, then references to objects have to be decremented.
If PyModule_AddObject fails, then references to objects have to be decremented.
fac5f07
to
c59fdb4
Compare
Thank you. ACK. |
Coverity warns that PyModule_AddIntConstant() returns operation success
or failure but this value is never checked.
Moreover, even though coverity doesn't indicate it the same happens with
PyModule_AddStringConstant().