summaryrefslogtreecommitdiff
path: root/daemon/digest.c
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/digest.c')
-rw-r--r--daemon/digest.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/daemon/digest.c b/daemon/digest.c
index 95f62f0..405a661 100644
--- a/daemon/digest.c
+++ b/daemon/digest.c
@@ -3,6 +3,7 @@
#include "md5.h"
#include "httpauthd.h"
#include "digest.h"
+#include "stringx.h"
#include <syslog.h>
@@ -145,10 +146,7 @@ int digest_parse(char* header, ha_buffer_t* buf, digest_header_t* rec,
while(header[0])
{
/* find key */
-
- while(header[0] && isspace(header[0]))
- header++;
-
+ header = (char*)trim_start(header);
key = header;
while(header[0] && header[0] != '=' && header[0] != ',' &&
@@ -165,9 +163,7 @@ int digest_parse(char* header, ha_buffer_t* buf, digest_header_t* rec,
if(isspace(header[0]))
{
- while(header[0] && isspace(header[0]))
- header++;
-
+ header = (char*)trim_start(header);
next = header[0];
}
@@ -175,8 +171,7 @@ int digest_parse(char* header, ha_buffer_t* buf, digest_header_t* rec,
if(next == '=')
{
- while(header[0] && isspace(header[0]))
- header++;
+ header = (char*)trim_start(header);
if(header[0] == '\"') /* quoted string */
{
@@ -252,7 +247,7 @@ int digest_parse(char* header, ha_buffer_t* buf, digest_header_t* rec,
return HA_OK;
}
-int digest_check(digest_header_t* dg, digest_record_t* rec, const ha_context_opts_t* opts,
+int digest_check(digest_header_t* dg, digest_record_t* rec, const ha_context_t* ctx,
ha_buffer_t* buf, const char* method, const char* uri)
{
unsigned char hash[MD5_LEN];
@@ -260,7 +255,7 @@ int digest_check(digest_header_t* dg, digest_record_t* rec, const ha_context_opt
const char* digest;
const char* t;
- ASSERT(opts && method && buf && dg && rec);
+ ASSERT(ctx && method && buf && dg && rec);
/* TODO: Many of these should somehow communicate BAD REQ back to the client */
@@ -291,7 +286,7 @@ int digest_check(digest_header_t* dg, digest_record_t* rec, const ha_context_opt
return HA_BADREQ;
}
- if(strcmp(dg->realm, opts->realm) != 0)
+ if(strcmp(dg->realm, ctx->realm) != 0)
{
ha_messagex(LOG_ERR, "digest response contains invalid realm: %s", dg->realm);
return HA_FALSE;
@@ -318,7 +313,7 @@ int digest_check(digest_header_t* dg, digest_record_t* rec, const ha_context_opt
return HA_BADREQ;
}
- if(!opts->digest_ignorenc)
+ if(!ctx->digest_ignorenc)
{
/* The nonce count */
if(!dg->nc || !dg->nc[0])
@@ -368,7 +363,7 @@ int digest_check(digest_header_t* dg, digest_record_t* rec, const ha_context_opt
return HA_BADREQ;
}
- if(!opts->digest_ignoreuri && strcmp(dg->uri, uri) != 0)
+ if(!ctx->digest_ignoreuri && strcmp(dg->uri, uri) != 0)
{
ha_uri_t d_uri;
ha_uri_t s_uri;