diff options
author | Endi S. Dewata <edewata@redhat.com> | 2010-07-09 20:48:45 -0500 |
---|---|---|
committer | Noriko Hosoi <nhosoi@redhat.com> | 2010-08-20 11:53:27 -0700 |
commit | e164ed7f97f1960a1b5ae83634bb89a0f2c23a58 (patch) | |
tree | e031462e3079612d7c50c207fe711a35fb61292a /ldap/servers | |
parent | 08e49c1de2ba34538b2b0122ea3ef3e1fb0e6c5e (diff) | |
download | ds-e164ed7f97f1960a1b5ae83634bb89a0f2c23a58.tar.gz ds-e164ed7f97f1960a1b5ae83634bb89a0f2c23a58.tar.xz ds-e164ed7f97f1960a1b5ae83634bb89a0f2c23a58.zip |
Bug 613056 - fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939
https://bugzilla.redhat.com/show_bug.cgi?id=613056
Resolves: bug 613056
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939
description: Catch possible NULL pointer in fix_ownership().
Diffstat (limited to 'ldap/servers')
-rw-r--r-- | ldap/servers/slapd/main.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c index d118a04b..2ad53b70 100644 --- a/ldap/servers/slapd/main.c +++ b/ldap/servers/slapd/main.c @@ -266,23 +266,29 @@ fix_ownership() slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - if (slapdFrontendConfig->localuser != NULL) { - if (slapdFrontendConfig->localuserinfo == NULL) { - pw = getpwnam( slapdFrontendConfig->localuser ); - if ( NULL == pw ) { - LDAPDebug(LDAP_DEBUG_ANY, - "Unable to find user %s in system account database, " - "errno %d (%s)\n", - slapdFrontendConfig->localuser, errno, strerror(errno)); - return; - } - slapdFrontendConfig->localuserinfo = - (struct passwd *)slapi_ch_malloc(sizeof(struct passwd)); - memcpy(slapdFrontendConfig->localuserinfo, pw, sizeof(struct passwd)); + if (slapdFrontendConfig->localuser == NULL) { + LDAPDebug(LDAP_DEBUG_ANY, + "Local user missing from frontend configuration\n", + 0, 0, 0); + return; + } + + if (slapdFrontendConfig->localuserinfo == NULL) { + pw = getpwnam( slapdFrontendConfig->localuser ); + if ( NULL == pw ) { + LDAPDebug(LDAP_DEBUG_ANY, + "Unable to find user %s in system account database, " + "errno %d (%s)\n", + slapdFrontendConfig->localuser, errno, strerror(errno)); + return; } - pw = slapdFrontendConfig->localuserinfo; + slapdFrontendConfig->localuserinfo = + (struct passwd *)slapi_ch_malloc(sizeof(struct passwd)); + memcpy(slapdFrontendConfig->localuserinfo, pw, sizeof(struct passwd)); } + pw = slapdFrontendConfig->localuserinfo; + /* config directory needs to be owned by the local user */ if (slapdFrontendConfig->configdir) { chown_dir_files(slapdFrontendConfig->configdir, pw, PR_FALSE); |