diff options
author | Felix Fietkau <nbd@openwrt.org> | 2014-12-05 11:56:18 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2014-12-10 17:01:03 +0100 |
commit | 71ca932167085f313711d4259393c5f3441cc3a8 (patch) | |
tree | 037c0d74e1813e7777c19be7c21b7f5fe9478148 /uclient-http.c | |
parent | 57a1dda8f31878282e554bb98d5cc81307edea49 (diff) | |
download | uclient-71ca932167085f313711d4259393c5f3441cc3a8.tar.gz |
http: fix processing of digest auth parameters
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'uclient-http.c')
-rw-r--r-- | uclient-http.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/uclient-http.c b/uclient-http.c index 7c5bc63..c25e52f 100644 --- a/uclient-http.c +++ b/uclient-http.c @@ -319,6 +319,22 @@ static char *digest_unquote_sep(char **str) return start; } +static char *digest_sep(char **str) +{ + char *cur, *next; + + cur = *str; + next = strchr(*str, ','); + if (next) { + *str = next + 1; + *next = 0; + } else { + *str += strlen(*str); + } + + return cur; +} + static bool strmatch(char **str, const char *prefix) { int len = strlen(prefix); @@ -413,8 +429,9 @@ uclient_http_add_auth_digest(struct uclient_http *uh) next = buf; while (*next) { const char **dest = NULL; + const char *tmp; - while (isspace(*next)) + while (*next && isspace(*next)) next++; if (strmatch(&next, "realm")) @@ -425,8 +442,18 @@ uclient_http_add_auth_digest(struct uclient_http *uh) dest = &data.nonce; else if (strmatch(&next, "opaque")) dest = &opaque; - else - return; + else if (strmatch(&next, "stale") || + strmatch(&next, "algorithm") || + strmatch(&next, "auth-param")) { + digest_sep(&next); + continue; + } else if (strmatch(&next, "domain") || + strmatch(&next, "qop-options")) + dest = &tmp; + else { + digest_sep(&next); + continue; + } *dest = digest_unquote_sep(&next); } |