summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'daemon')
-rw-r--r--daemon/bd.c8
-rw-r--r--daemon/ldap.c23
-rw-r--r--daemon/mysql.c4
-rw-r--r--daemon/pgsql.c2
4 files changed, 20 insertions, 17 deletions
diff --git a/daemon/bd.c b/daemon/bd.c
index 09dc45f..cb4f2cf 100644
--- a/daemon/bd.c
+++ b/daemon/bd.c
@@ -140,7 +140,7 @@ static int save_cached_digest(bd_context_t* ctx, ha_context_t* c,
if(!r)
{
- ha_messagex(NULL, LOG_CRIT, "out of memory");
+ ha_memerr(NULL);
return HA_CRITERROR;
}
@@ -168,7 +168,7 @@ static int add_cached_basic(bd_context_t* ctx, ha_context_t* c,
if(!r)
{
- ha_messagex(NULL, LOG_CRIT, "out of memory");
+ ha_memerr(NULL);
return HA_CRITERROR;
}
@@ -183,7 +183,7 @@ digest_record_t* make_digest_rec(unsigned char* nonce, const char* user)
if(!rec)
{
- ha_messagex(NULL, LOG_CRIT, "out of memory");
+ ha_memerr(NULL);
return NULL;
}
@@ -569,7 +569,7 @@ int bd_init(ha_context_t* context)
/* The cache for digest records and basic */
if(!(ctx->cache = hsh_create(MD5_LEN)))
{
- ha_messagex(NULL, LOG_CRIT, "out of memory");
+ ha_memerr(NULL);
return HA_CRITERROR;
}
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;
}
diff --git a/daemon/mysql.c b/daemon/mysql.c
index d3f3271..091a607 100644
--- a/daemon/mysql.c
+++ b/daemon/mysql.c
@@ -315,7 +315,7 @@ static MYSQL* get_mysql_connection(const ha_request_t* rq, mysql_context_t* ctx)
my = mysql_init(NULL);
if(!my)
{
- ha_messagex(rq, LOG_ERR, "out of memory");
+ ha_memerr(rq);
return NULL;
}
@@ -762,7 +762,7 @@ int mysql_initialize(ha_context_t* context)
ctx->pool = (MYSQL**)malloc(sizeof(MYSQL*) * ctx->mysql_max);
if(!ctx->pool)
{
- ha_messagex(NULL, LOG_CRIT, "out of memory");
+ ha_memerr(NULL);
return HA_CRITERROR;
}
diff --git a/daemon/pgsql.c b/daemon/pgsql.c
index 1870049..13ecd85 100644
--- a/daemon/pgsql.c
+++ b/daemon/pgsql.c
@@ -799,7 +799,7 @@ int pgsql_init(ha_context_t* context)
ctx->pool = (PGconn**)malloc(sizeof(PGconn*) * ctx->pgsql_max);
if(!ctx->pool)
{
- ha_messagex(NULL, LOG_CRIT, "out of memory");
+ ha_memerr(NULL);
return HA_CRITERROR;
}