diff options
author | Lukas Slebodnik <lslebodn@redhat.com> | 2014-08-26 12:59:53 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-09-05 17:34:04 +0200 |
commit | d79c604c5080c5f6e2bf2d91b4ae79a562437c74 (patch) | |
tree | f77dd6598d01fe26ddc3e94de5920d095ca88ae1 | |
parent | 61b58801f1e37c054affc99f6fe900f7b3ef7972 (diff) | |
download | sssd-d79c604c5080c5f6e2bf2d91b4ae79a562437c74.tar.gz sssd-d79c604c5080c5f6e2bf2d91b4ae79a562437c74.tar.xz sssd-d79c604c5080c5f6e2bf2d91b4ae79a562437c74.zip |
pysss: test return value of realloc.
It is not very likely that realloc will return NULL, but it's better
to be defensive.
src/python/pysss.c:774: var_assigned: Assigning: "groups" = null return value from "realloc".
src/python/pysss.c:788: dereference: Dereferencing a null pointer "groups".
Reviewed-by: Pavel Reichl <preichl@redhat.com>
-rw-r--r-- | src/python/pysss.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/python/pysss.c b/src/python/pysss.c index 668d77c56..8f98f081c 100644 --- a/src/python/pysss.c +++ b/src/python/pysss.c @@ -771,7 +771,11 @@ static PyObject *py_sss_getgrouplist(PyObject *self, PyObject *args) do { ret = getgrouplist(username, pw->pw_gid, groups, &ngroups); if (ret < ngroups) { - groups = realloc(groups, ngroups * sizeof(gid_t)); + gid_t *tmp_groups = realloc(groups, ngroups * sizeof(gid_t)); + if (tmp_groups == NULL) { + goto fail; + } + groups = tmp_groups; } } while (ret != ngroups); |