From cc98e19b424861c2a7fd91e0d657d82c1dbf3059 Mon Sep 17 00:00:00 2001 From: Pavel Reichl Date: Thu, 21 May 2015 10:19:59 -0400 Subject: localauth plugin: fix coverity warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Error: FORWARD_NULL (CWE-476): [#def1] sssd-1.12.90/src/krb5_plugin/sssd_krb5_localauth_plugin.c:111: assign_zero: Assigning: "pwd.pw_name" = "NULL". sssd-1.12.90/src/krb5_plugin/sssd_krb5_localauth_plugin.c:142: var_deref_model: Passing null pointer "pwd.pw_name" to "strdup", which dereferences it. 140| } 141| 142|-> str = strdup(pwd.pw_name); 143| if (str == NULL) { 144| ret = ENOMEM; Reviewed-by: Pavel Březina --- src/krb5_plugin/sssd_krb5_localauth_plugin.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/krb5_plugin') diff --git a/src/krb5_plugin/sssd_krb5_localauth_plugin.c b/src/krb5_plugin/sssd_krb5_localauth_plugin.c index 83a286689..1e77d5227 100644 --- a/src/krb5_plugin/sssd_krb5_localauth_plugin.c +++ b/src/krb5_plugin/sssd_krb5_localauth_plugin.c @@ -139,6 +139,11 @@ static krb5_error_code sss_an2ln(krb5_context context, goto done; } + if (pwd.pw_name == NULL) { + ret = EINVAL; + goto done; + } + str = strdup(pwd.pw_name); if (str == NULL) { ret = ENOMEM; -- cgit