Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2013-02-23 22:11:13 +0100
committerArthur de Jong <arthur@arthurdejong.org>2013-02-23 22:11:13 +0100
commit59873eb9cd82f7aa6e41e878ef395bfa4bf738fc (patch)
treefe895cdb679b4138ab7dfb9e1078d6e600c36068
parent295036849a30b68201ffe6965386b2e4d5b32b25 (diff)
fix a problem in memory handling in myldap_get_values_len() if malloc() would fail (r1909 from 0.9)
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd-0.8@1932 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r--nslcd/myldap.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/nslcd/myldap.c b/nslcd/myldap.c
index 3cc9da5..1922a93 100644
--- a/nslcd/myldap.c
+++ b/nslcd/myldap.c
@@ -1572,8 +1572,7 @@ static const char **bervalues_to_values(struct berval **bvalues)
values=(char **)malloc(sz);
if (values==NULL)
{
- log_log(LOG_CRIT,"myldap_get_values_len(): malloc() failed to allocate memory");
- ldap_value_free_len(bvalues);
+ log_log(LOG_CRIT,"bervalues_to_values(): malloc() failed to allocate memory");
return NULL;
}
buf=(char *)values;
@@ -1649,6 +1648,9 @@ const char **myldap_get_values_len(MYLDAP_ENTRY *entry,const char *attr)
values=bervalues_to_values(bvalues);
ldap_value_free_len(bvalues);
}
+ /* check if we got allocated memory */
+ if (values==NULL)
+ return NULL;
/* store values entry so we can free it later on */
for (i=0;i<MAX_RANGED_ATTRIBUTES_PER_ENTRY;i++)
if (entry->rangedattributevalues[i]==NULL)