diff options
author | Benny Prijono <bennylp@teluu.com> | 2009-11-06 04:16:36 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2009-11-06 04:16:36 +0000 |
commit | b56287e036a80265bef7afe273a4854d9b55587e (patch) | |
tree | 5f8d96277c6576d446e4f8b55e7ee5c93221f736 /pjsip/src | |
parent | 1f67de36d13cf9268d518b035bb3b9bd09e5b923 (diff) |
Fixed ticket #986: Assertion when authorization PJSIP_AUTH_AUTO_SEND_NEXT is enabled (thanks Zhefeng Du for the report)
- also added SIPp scenario for testing
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2988 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src')
-rw-r--r-- | pjsip/src/pjsip/sip_auth_client.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/pjsip/src/pjsip/sip_auth_client.c b/pjsip/src/pjsip/sip_auth_client.c index d232229c..66c8c65b 100644 --- a/pjsip/src/pjsip/sip_auth_client.c +++ b/pjsip/src/pjsip/sip_auth_client.c @@ -322,8 +322,33 @@ static void update_digest_session( pj_pool_t *ses_pool, pjsip_cached_auth *cached_auth, const pjsip_www_authenticate_hdr *hdr ) { - if (hdr->challenge.digest.qop.slen == 0) + if (hdr->challenge.digest.qop.slen == 0) { +#if PJSIP_AUTH_AUTO_SEND_NEXT!=0 + if (!cached_auth->last_chal || pj_stricmp2(&hdr->scheme, "digest")) { + cached_auth->last_chal = (pjsip_www_authenticate_hdr*) + pjsip_hdr_clone(ses_pool, hdr); + } else { + /* Only update if the new challenge is "significantly different" + * than the one in the cache, to reduce memory usage. + */ + const pjsip_digest_challenge *d1 = + &cached_auth->last_chal->challenge.digest; + const pjsip_digest_challenge *d2 = &hdr->challenge.digest; + + if (pj_strcmp(&d1->domain, &d2->domain) || + pj_strcmp(&d1->realm, &d2->realm) || + pj_strcmp(&d1->nonce, &d2->nonce) || + pj_strcmp(&d1->opaque, &d2->opaque) || + pj_strcmp(&d1->algorithm, &d2->algorithm) || + pj_strcmp(&d1->qop, &d2->qop)) + { + cached_auth->last_chal = (pjsip_www_authenticate_hdr*) + pjsip_hdr_clone(ses_pool, hdr); + } + } +#endif return; + } /* Initialize cnonce and qop if not present. */ if (cached_auth->cnonce.slen == 0) { |