From 85aeddc9c04b1c822b61e01527d4dea6f7fdf0c9 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Thu, 29 Apr 2010 00:03:19 +0000 Subject: Fixed #1061 (Assertion when receiving authentication challenge with empty realm (thanks Andrey Kovalenko for the report)): - removed the assertion (allow responding to empty realm) - slight modification in Authenticate/WWW-Authenticate headers to allow printing challenge with empty realm, otherwise a malformed header will be printed if empty realm is given git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3149 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsip/sip_auth_client.c | 2 ++ pjsip/src/pjsip/sip_auth_msg.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pjsip/src/pjsip/sip_auth_client.c b/pjsip/src/pjsip/sip_auth_client.c index e1667c96..df904e4f 100644 --- a/pjsip/src/pjsip/sip_auth_client.c +++ b/pjsip/src/pjsip/sip_auth_client.c @@ -393,7 +393,9 @@ static void update_digest_session( pj_pool_t *ses_pool, cached_auth->nc = 1; /* Save realm. */ + /* Note: allow empty realm (http://trac.pjsip.org/repos/ticket/1061) pj_assert(cached_auth->realm.slen != 0); + */ if (cached_auth->realm.slen == 0) { pj_strdup(ses_pool, &cached_auth->realm, &hdr->challenge.digest.realm); diff --git a/pjsip/src/pjsip/sip_auth_msg.c b/pjsip/src/pjsip/sip_auth_msg.c index 2def9ab0..26477cc0 100644 --- a/pjsip/src/pjsip/sip_auth_msg.c +++ b/pjsip/src/pjsip/sip_auth_msg.c @@ -232,7 +232,8 @@ static int print_digest_challenge( pjsip_digest_challenge *chal, char *endbuf = buf + size; const pjsip_parser_const_t *pc = pjsip_parser_const(); - copy_advance_pair_quote_cond(buf, " realm=", 7, chal->realm, '"', '"'); + /* Allow empty realm, see http://trac.pjsip.org/repos/ticket/1061 */ + copy_advance_pair_quote(buf, " realm=", 7, chal->realm, '"', '"'); copy_advance_pair_quote_cond(buf, ",domain=", 8, chal->domain, '"', '"'); copy_advance_pair_quote_cond(buf, ",nonce=", 7, chal->nonce, '"', '"'); copy_advance_pair_quote_cond(buf, ",opaque=", 8, chal->opaque, '"', '"'); -- cgit v1.2.3