From 5ad0d9d9b1e70761bb1f873ac2d8a0db5d39f479 Mon Sep 17 00:00:00 2001 From: Andrew Pogrebennyk Date: Sun, 16 Dec 2012 17:22:53 +0000 Subject: [PATCH] try to fix a bug in find_credentials with more than one Authorization headers --- parser/digest/digest.c | 17 ++++++++++------- pkg/kamailio/deb/squeeze/changelog | 6 +++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/parser/digest/digest.c b/parser/digest/digest.c index a22393c5c..2aef8e1f3 100644 --- a/parser/digest/digest.c +++ b/parser/digest/digest.c @@ -241,7 +241,7 @@ int get_authorized_cred(struct hdr_field* _f, struct hdr_field** _h) int find_credentials(struct sip_msg* msg, str* realm, hdr_types_t hftype, struct hdr_field** hdr) { - struct hdr_field** hook, *ptr, *prev; + struct hdr_field** hook, *ptr; hdr_flags_t hdr_flags; int res; str* r; @@ -290,7 +290,7 @@ int find_credentials(struct sip_msg* msg, str* realm, return (res == -1) ? -2 : -3; } else if (res == 0) { r = &(((auth_body_t*)(ptr->parsed))->digest.realm); - DBG("auth:find_credentials: compare realm '%.*s', len %d to parsed realm '%.*s', len %d\n", realm->s, realm->len, r->s, r->len); + if (r->len == realm->len) { if (!strncasecmp(realm->s, r->s, r->len)) { *hdr = ptr; @@ -299,15 +299,18 @@ int find_credentials(struct sip_msg* msg, str* realm, } } - prev = ptr; if (parse_headers(msg, hdr_flags, 1) == -1) { LOG(L_ERR, "auth:find_credentials: Error while parsing headers\n"); return -4; } else { - if (prev != msg->last_header) { - if (msg->last_header->type == hftype) ptr = msg->last_header; - else break; - } else break; + ptr = ptr->next; + while (ptr) { + if (ptr->type == hftype) + break; + ptr = ptr->next; + } + if (!ptr) + break; } } diff --git a/pkg/kamailio/deb/squeeze/changelog b/pkg/kamailio/deb/squeeze/changelog index c45d9b51d..904923b9d 100644 --- a/pkg/kamailio/deb/squeeze/changelog +++ b/pkg/kamailio/deb/squeeze/changelog @@ -1,8 +1,8 @@ -kamailio (3.3+ngcp2.6.11) unstable; urgency=low +kamailio (3.3+ngcp2.6.12) unstable; urgency=low - * Add experimental debugging for find_credentials. + * Don't stop after first Authorization header if all message is already parsed in find_credentials. - -- Andrew Pogrebennyk Sun, 16 Dec 2012 11:38:23 +0100 + -- Andrew Pogrebennyk Sun, 16 Dec 2012 18:21:47 +0100 kamailio (3.3+ngcp2.6.10) unstable; urgency=low