diff options
author | Lukas Slebodnik <lslebodn@redhat.com> | 2014-03-07 09:26:22 +0100 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-03-07 21:30:49 +0100 |
commit | 441c0f5e1e05db77c62f3281525345ff322b0a65 (patch) | |
tree | 3ab4cf7f20098b9659ca514db6700dda50da231e /src/sss_client | |
parent | b93fe4ec821f997fba5058bf5e76ff77c3a39026 (diff) | |
download | sssd-441c0f5e1e05db77c62f3281525345ff322b0a65.tar.gz sssd-441c0f5e1e05db77c62f3281525345ff322b0a65.tar.xz sssd-441c0f5e1e05db77c62f3281525345ff322b0a65.zip |
PAM: Test return value of strdup
Warnings reported by Coverity (12463,12464)
Dereferencing a pointer that might be null pi->pam_authtok when calling strlen.
Dereferencing a pointer that might be null action when calling strncmp.
Reviewed-by: Stephen Gallagher <sgallagh@redhat.com>
Diffstat (limited to 'src/sss_client')
-rw-r--r-- | src/sss_client/pam_sss.c | 4 | ||||
-rw-r--r-- | src/sss_client/pam_test_client.c | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/sss_client/pam_sss.c b/src/sss_client/pam_sss.c index 638e211ee..d45b2e88f 100644 --- a/src/sss_client/pam_sss.c +++ b/src/sss_client/pam_sss.c @@ -1368,6 +1368,10 @@ static int get_authtok_for_password_change(pam_handle_t *pamh, } } else { pi->pam_authtok = strdup(pi->pamstack_oldauthtok); + if (pi->pam_authtok == NULL) { + D(("strdup failed")); + return PAM_BUF_ERR; + } pi->pam_authtok_type = SSS_AUTHTOK_TYPE_PASSWORD; pi->pam_authtok_size = strlen(pi->pam_authtok); } diff --git a/src/sss_client/pam_test_client.c b/src/sss_client/pam_test_client.c index ef424e77c..af8a0da90 100644 --- a/src/sss_client/pam_test_client.c +++ b/src/sss_client/pam_test_client.c @@ -53,6 +53,11 @@ int main(int argc, char *argv[]) { user = strdup(argv[2]); } + if (action == NULL || user == NULL) { + fprintf(stderr, "Out of memory!\n"); + return 1; + } + fprintf(stdout, "action: %s\nuser: %s\n", action,user); ret = pam_start("sss_test", user, &conv, &pamh); |