Module: sip-router
Branch: 3.3
Commit: 74460a7e75fe6c8be1dee475b93e1765f5c72a3e
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=74460a7e75fe6c8be1dee475b93e1765f5c72a3e

Author: Richard Fuchs <[email protected]>
Committer: Richard Fuchs <[email protected]>
Date:   Sun Dec 16 15:06:32 2012 -0500

parser/digest: Fix hunting for Auth header in rare cases

Fix a bug where find_credentials() would fail to find the correct
Auth header when multiple headers are present, the one being looked
for isn't the first and the full message had been parsed already.

---

 parser/digest/digest.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/parser/digest/digest.c b/parser/digest/digest.c
index 66400b5..2aef8e1 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;
@@ -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;
                }
        }
        


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to