summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-12-05 07:35:57 +0000
committerAndrew Tridgell <tridge@samba.org>2001-12-05 07:35:57 +0000
commit0799c446809a7ae239864e69995849431cd2cb00 (patch)
treec24b43b26f86540725ed795366044812e40e78d4
parentcb01c8e192f24dd4ef5af6f04ef31707090fe5fa (diff)
downloadsamba-0799c446809a7ae239864e69995849431cd2cb00.tar.gz
samba-0799c446809a7ae239864e69995849431cd2cb00.tar.bz2
samba-0799c446809a7ae239864e69995849431cd2cb00.zip
paranoia fixes in based ldap routines for potential memory leaks
(This used to be commit 13b933104e1389608e4831ca47dd8106ea0c60a5)
-rw-r--r--source3/libads/ldap.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 251a4a6958..5b391f1282 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -446,13 +446,14 @@ char *ads_pull_string(ADS_STRUCT *ads,
TALLOC_CTX *mem_ctx, void *msg, const char *field)
{
char **values;
- char *ret;
+ char *ret = NULL;
values = ldap_get_values(ads->ld, msg, field);
-
- if (!values || !values[0]) return NULL;
-
- ret = talloc_strdup(mem_ctx, values[0]);
+ if (!values) return NULL;
+
+ if (values[0]) {
+ ret = talloc_strdup(mem_ctx, values[0]);
+ }
ldap_value_free(values);
return ret;
}
@@ -466,8 +467,11 @@ BOOL ads_pull_uint32(ADS_STRUCT *ads,
char **values;
values = ldap_get_values(ads->ld, msg, field);
-
- if (!values || !values[0]) return False;
+ if (!values) return False;
+ if (!values[0]) {
+ ldap_value_free(values);
+ return False;
+ }
*v = atoi(values[0]);
ldap_value_free(values);
@@ -481,13 +485,15 @@ BOOL ads_pull_sid(ADS_STRUCT *ads,
void *msg, const char *field, DOM_SID *sid)
{
struct berval **values;
- BOOL ret;
+ BOOL ret = False;
values = ldap_get_values_len(ads->ld, msg, field);
- if (!values || !values[0]) return False;
+ if (!values) return False;
- ret = sid_parse(values[0]->bv_val, values[0]->bv_len, sid);
+ if (values[0]) {
+ ret = sid_parse(values[0]->bv_val, values[0]->bv_len, sid);
+ }
ldap_value_free_len(values);
return ret;