Module: sip-router Branch: master Commit: 1c9ccc12371b38f546ba874ab8b82d775ad112f3 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=1c9ccc12...
Author: Marius Zbihlei marius.zbihlei@1and1.ro Committer: Marius Zbihlei marius.zbihlei@1and1.ro Date: Mon Jan 17 12:06:55 2011 +0200
modules/auth Fixed a bug when realm is NULL in challenge method
---
modules/auth/challenge.c | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/modules/auth/challenge.c b/modules/auth/challenge.c index 9bd4ce0..decebf0 100644 --- a/modules/auth/challenge.c +++ b/modules/auth/challenge.c @@ -124,9 +124,13 @@ int get_challenge_hf(struct sip_msg* msg, int stale, str* realm, nonce_len = get_nonce_len(cfg, nc_enabled || otn_enabled);
hf.len = hfn->len; - hf.len += DIGEST_REALM_LEN - + realm->len - + DIGEST_NONCE_LEN; + if (realm) { + hf.len += DIGEST_REALM_LEN + + realm->len; + } + + hf.len += DIGEST_NONCE_LEN; + if (nonce) { hf.len += nonce->len + 1; /* '"' */ @@ -156,10 +160,14 @@ int get_challenge_hf(struct sip_msg* msg, int stale, str* realm, ERR("auth: No memory left (%d bytes)\n", hf.len); return -1; } - + memcpy(p, hfn->s, hfn->len); p += hfn->len; - memcpy(p, DIGEST_REALM, DIGEST_REALM_LEN); p += DIGEST_REALM_LEN; - memcpy(p, realm->s, realm->len); p += realm->len; + + if(realm){ + memcpy(p, DIGEST_REALM, DIGEST_REALM_LEN); p += DIGEST_REALM_LEN; + memcpy(p, realm->s, realm->len); p += realm->len; + } + memcpy(p, DIGEST_NONCE, DIGEST_NONCE_LEN); p += DIGEST_NONCE_LEN; if (nonce) { memcpy(p, nonce->s, nonce->len); p += nonce->len;