summaryrefslogtreecommitdiff
path: root/daemon/ldap.c
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2005-03-22 23:59:38 +0000
committerStef Walter <stef@memberwebs.com>2005-03-22 23:59:38 +0000
commit84f393a6cf75df90c7836fc2f3356a5543983779 (patch)
tree6de338710d462172e3cd6a31d946e4ae99d55268 /daemon/ldap.c
parent3ecaf9c3c9bb83f5e611beaeeccc19909630036a (diff)
Fix memory and buffer problems.
Diffstat (limited to 'daemon/ldap.c')
-rw-r--r--daemon/ldap.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/daemon/ldap.c b/daemon/ldap.c
index 946e5ed..2c8f915 100644
--- a/daemon/ldap.c
+++ b/daemon/ldap.c
@@ -145,7 +145,7 @@ static int report_ldap(const ha_request_t* rq, const char* msg, int code)
switch(code)
{
case LDAP_NO_MEMORY:
- ha_messagex(NULL, LOG_CRIT, "out of memory");
+ ha_memerr(NULL);
return HA_CRITERROR;
default:
@@ -656,7 +656,7 @@ static int validate_digest(ha_request_t* rq, const char* user, digest_context_t*
LDAP* ld = NULL; /* freed in finally */
LDAPMessage* results = NULL; /* freed in finally */
LDAPMessage* entry = NULL; /* no need to free */
- struct berval** ha1s = NULL; /* freed manually */
+ struct berval** ha1s = NULL; /* freed in finally */
const char** pws = NULL; /* freed in finally */
int ret = HA_FALSE;
const char* dn = NULL;
@@ -696,10 +696,11 @@ static int validate_digest(ha_request_t* rq, const char* user, digest_context_t*
if(ha1s && *ha1s)
{
int foundinvalid = 0;
+ struct berval** h = NULL;
- while(*ha1s)
- {
- r = parse_ldap_ha1(rq, *ha1s, dg->ha1);
+ for(h = ha1s; *h; ++h)
+ {
+ r = parse_ldap_ha1(rq, *h, dg->ha1);
if(r == HA_FALSE)
{
@@ -719,8 +720,6 @@ static int validate_digest(ha_request_t* rq, const char* user, digest_context_t*
else if(r < 0)
RETURN(r);
-
- ha1s++;
}
if(foundinvalid)
@@ -732,18 +731,22 @@ static int validate_digest(ha_request_t* rq, const char* user, digest_context_t*
if(pws && *pws)
{
+ const char** p = pws;
+
/* Find a cleartext password */
- while((pws = find_cleartext_password(rq->buf, pws)))
+ while((p = find_cleartext_password(rq->buf, p)))
{
foundany = 1;
- digest_makeha1(dg->ha1, user, rq->context->realm, *pws);
+ digest_makeha1(dg->ha1, user, rq->context->realm, *p);
/* Run the actual check */
ret = digest_complete_check(dg, rq->buf);
if(ret != HA_FALSE)
RETURN(ret);
+
+ p++;
}
}
@@ -1026,7 +1029,7 @@ int ldap_inithand(ha_context_t* context)
ctx->pool = (LDAP**)malloc(sizeof(LDAP*) * ctx->ldap_max);
if(!ctx->pool)
{
- ha_messagex(NULL, LOG_CRIT, "out of memory");
+ ha_memerr(NULL);
return HA_CRITERROR;
}