On Sunday 16 December 2012, Richard Fuchs wrote:

> +                     ptr = ptr->next;
> +                     while (ptr) {
> +                             if (ptr->type == hftype)
> +                                     break;
> +                             ptr = ptr->next;
> +                     }
> +                     if (!ptr)
> +                             break;


There is a dedicated function for walking the sibling headers: 
next_sibling_hdr(). Please consider using it instead of open coding the 
loop. Like in attached patch i should have pushed log time ago ;)


-- 
Alex Hermann

From 39b5352f5cfde6c62252fa106b13649bac53f71a Mon Sep 17 00:00:00 2001
From: Alex Hermann <[email protected]>
Date: Tue, 30 Aug 2011 13:34:17 +0200
Subject: [PATCH] parser/digest: check for sibling Authorization headers before parsing rest of message

Multiple Authorization may be present in a message. When finding the one with
the correct realm, first consider header siblings before parsing the rest of
the message. With this change, the correct header will be found if it is not
the first.
---
 parser/digest/digest.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/parser/digest/digest.c b/parser/digest/digest.c
index 66400b5..d2fa274 100644
--- a/parser/digest/digest.c
+++ b/parser/digest/digest.c
@@ -300,6 +300,9 @@ int find_credentials(struct sip_msg* msg, str* realm,
 		}
 
 		prev = ptr;
+		ptr = next_sibling_hdr(ptr);
+		if (ptr != NULL)
+			continue;
 		if (parse_headers(msg, hdr_flags, 1) == -1) {
 			LOG(L_ERR, "auth:find_credentials: Error while parsing headers\n");
 			return -4;
-- 
1.7.2.5

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

Reply via email to