Module: sip-router
Branch: master
Commit: 624a9bbf777a1c1d44400eec78911a9714872977
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=624a9bbf777a1c1d44400eec78911a9714872977

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 064f42e..512ce31 100644
--- a/parser/digest/digest.c
+++ b/parser/digest/digest.c
@@ -239,7 +239,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;
@@ -297,15 +297,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