From 84f393a6cf75df90c7836fc2f3356a5543983779 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 22 Mar 2005 23:59:38 +0000 Subject: Fix memory and buffer problems. --- daemon/ldap.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'daemon/ldap.c') 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; } -- cgit v1.2.3