From 71674cc69ba19cb8a4229b31daa5a7a2153b0ded Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Thu, 17 Jan 2013 10:09:09 +0000 Subject: Really fix #1609 after better understanding about the problem. This changeset: - undo r4320 - remove the reliance on NULL termination in sip_auth_client.c - add the NULL termination when printing tel: URI just in case other components use it git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4322 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsip/sip_auth_client.c | 18 +++++++----------- pjsip/src/pjsip/sip_tel_uri.c | 4 +++- 2 files changed, 10 insertions(+), 12 deletions(-) (limited to 'pjsip') diff --git a/pjsip/src/pjsip/sip_auth_client.c b/pjsip/src/pjsip/sip_auth_client.c index da2be3e9..3cea533b 100644 --- a/pjsip/src/pjsip/sip_auth_client.c +++ b/pjsip/src/pjsip/sip_auth_client.c @@ -920,18 +920,15 @@ PJ_DEF(pj_status_t) pjsip_auth_clt_init_req( pjsip_auth_clt_sess *sess, * or add an empty authorization header. */ unsigned i; - char *uri_str; - int len; + pj_str_t uri; - uri_str = (char*)pj_pool_alloc(tdata->pool, PJSIP_MAX_URL_SIZE+1); - len = pjsip_uri_print(PJSIP_URI_IN_REQ_URI, tdata->msg->line.req.uri, - uri_str, PJSIP_MAX_URL_SIZE); - if (len < 1 || len >= PJSIP_MAX_URL_SIZE) + uri.ptr = (char*)pj_pool_alloc(tdata->pool, PJSIP_MAX_URL_SIZE); + uri.slen = pjsip_uri_print(PJSIP_URI_IN_REQ_URI, + tdata->msg->line.req.uri, + uri.ptr, PJSIP_MAX_URL_SIZE); + if (uri.slen < 1 || uri.slen >= PJSIP_MAX_URL_SIZE) return PJSIP_EURITOOLONG; - /* https://trac.pjsip.org/repos/ticket/1609 */ - uri_str[len] = '\0'; - for (i=0; icred_cnt; ++i) { pjsip_cred_info *c = &sess->cred_info[i]; pjsip_authorization_hdr *h; @@ -949,8 +946,7 @@ PJ_DEF(pj_status_t) pjsip_auth_clt_init_req( pjsip_auth_clt_sess *sess, &c->username); pj_strdup(tdata->pool, &hs->credential.digest.realm, &c->realm); - pj_strdup2(tdata->pool, &hs->credential.digest.uri, - uri_str); + pj_strdup(tdata->pool, &hs->credential.digest.uri, &uri); pj_strdup(tdata->pool, &hs->credential.digest.algorithm, &sess->pref.algorithm); diff --git a/pjsip/src/pjsip/sip_tel_uri.c b/pjsip/src/pjsip/sip_tel_uri.c index c6bb5ba2..606e18c3 100644 --- a/pjsip/src/pjsip/sip_tel_uri.c +++ b/pjsip/src/pjsip/sip_tel_uri.c @@ -182,7 +182,7 @@ static pj_ssize_t tel_uri_print( pjsip_uri_context_e context, { int printed; char *startbuf = buf; - char *endbuf = buf+size; + char *endbuf = buf+size-1; const pjsip_parser_const_t *pc = pjsip_parser_const(); PJ_UNUSED_ARG(context); @@ -217,6 +217,8 @@ static pj_ssize_t tel_uri_print( pjsip_uri_context_e context, return -1; buf += printed; + *buf = '\0'; + return (buf-startbuf); } -- cgit v1.2.3