diff options
-rw-r--r-- | pjsip/include/pjsip/print_util.h | 17 | ||||
-rw-r--r-- | pjsip/src/pjsip/sip_auth_msg.c | 3 |
2 files changed, 19 insertions, 1 deletions
diff --git a/pjsip/include/pjsip/print_util.h b/pjsip/include/pjsip/print_util.h index d2ee3aea..f8f9eb01 100644 --- a/pjsip/include/pjsip/print_util.h +++ b/pjsip/include/pjsip/print_util.h @@ -105,6 +105,10 @@ #define copy_advance copy_advance_check #define copy_advance_pair copy_advance_pair_check +/* + * Append str1 and quoted str2 and copy to buf. + * No string is copied if str2 is empty. + */ #define copy_advance_pair_quote_cond(buf,str1,len1,str2,quotebegin,quoteend) \ do { \ if (str2.slen && *str2.ptr!=quotebegin) \ @@ -114,6 +118,19 @@ } while (0) /* + * Append str1 and quoted str2 and copy to buf. + * In case str2 is empty, str1 will be appended with empty quote. + */ +#define copy_advance_pair_quote_cond_always(buf,str1,len1,str2,quotebegin, \ + quoteend)\ + do { \ + if (!str2.slen) \ + copy_advance_pair_quote(buf,str1,len1,str2,quotebegin,quoteend); \ + else \ + copy_advance_pair_quote_cond(buf,str1,len1,str2,quotebegin,quoteend);\ + } while (0) + +/* * Internal type declarations. */ typedef void* (*pjsip_hdr_clone_fptr)(pj_pool_t *, const void*); diff --git a/pjsip/src/pjsip/sip_auth_msg.c b/pjsip/src/pjsip/sip_auth_msg.c index 0f37fae2..fd42b697 100644 --- a/pjsip/src/pjsip/sip_auth_msg.c +++ b/pjsip/src/pjsip/sip_auth_msg.c @@ -71,7 +71,8 @@ static int print_digest_credential(pjsip_digest_credential *cred, char *buf, pj_ const pjsip_parser_const_t *pc = pjsip_parser_const(); copy_advance_pair_quote_cond(buf, "username=", 9, cred->username, '"', '"'); - copy_advance_pair_quote_cond(buf, ", realm=", 8, cred->realm, '"', '"'); + copy_advance_pair_quote_cond_always(buf, ", realm=", 8, cred->realm, '"', + '"'); copy_advance_pair_quote(buf, ", nonce=", 8, cred->nonce, '"', '"'); copy_advance_pair_quote_cond(buf, ", uri=", 6, cred->uri, '"', '"'); copy_advance_pair_quote(buf, ", response=", 11, cred->response, '"', '"'); |