Skip to content

Commit

Permalink
Merge branch 'master' into cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
azzbcc committed Jun 16, 2021
2 parents 93e43bc + 6901dbf commit 5b5da8f
Show file tree
Hide file tree
Showing 17 changed files with 282 additions and 56 deletions.
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dnl information on the package
dnl ---------------------------

dnl update both the version for AC_INIT and the LIBSOFIA_SIP_UA_MAJOR_MINOR
AC_INIT([sofia-sip], [1.13.3])
AC_INIT([sofia-sip], [1.13.4])

CFLAGS="$CFLAGS $CONFIGURE_CFLAGS"
CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS"
Expand All @@ -22,9 +22,9 @@ AC_CONFIG_MACRO_DIR([m4])
AC_SUBST(VER_LIBSOFIA_SIP_UA_MAJOR_MINOR, [1.13])
dnl Includedir specific to this sofia version
AC_SUBST(include_sofiadir, '${includedir}/sofia-sip-1.13')
AC_SUBST(LIBVER_SOFIA_SIP_UA_CUR, [6])
AC_SUBST(LIBVER_SOFIA_SIP_UA_CUR, [4])
AC_SUBST(LIBVER_SOFIA_SIP_UA_REV, [0])
AC_SUBST(LIBVER_SOFIA_SIP_UA_AGE, [6])
AC_SUBST(LIBVER_SOFIA_SIP_UA_AGE, [4])
AC_SUBST(LIBVER_SOFIA_SIP_UA_SOVER, [0]) # CUR-AGE
AC_SUBST(LIBVER_SOFIA_SIP_UA_GLIB_CUR, [3])
AC_SUBST(LIBVER_SOFIA_SIP_UA_GLIB_REV, [0])
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
sofia-sip (1.13.4-1) unstable; urgency=medium

* New Release.

-- FreeSWITCH Solutions <[email protected]> Mon, 14 Jun 2021 19:20:09 +0200

sofia-sip (1.13.3-1) unstable; urgency=medium

* New Release.
Expand Down
2 changes: 1 addition & 1 deletion libsofia-sip-ua/iptsec/auth_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ static int auc_digest_challenge(auth_client_t *ca, msg_auth_t const *ch)
goto error;

/* Check that we can handle the challenge */
if (!ac->ac_md5 && !ac->ac_md5sess)
if (!ac->ac_md5 && !ac->ac_md5sess && !ac->ac_sha256 && !ac->ac_sha256sess && !ac->ac_sha512_256 && !ac->ac_sha512_256sess)
goto error;
if (ac->ac_qop && !ac->ac_auth && !ac->ac_auth_int)
goto error;
Expand Down
9 changes: 9 additions & 0 deletions libsofia-sip-ua/iptsec/auth_digest.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ issize_t auth_digest_challenge_get(su_home_t *home,
ssize_t n;
auth_challenge_t ac[1] = {{ 0 }};
char const *md5 = NULL, *md5sess = NULL, *sha1 = NULL,
*sha256 = NULL, *sha256sess = NULL, *sha512_256 = NULL, *sha512_256sess = NULL,
*stale = NULL,
*qop_auth = NULL, *qop_auth_int = NULL;

Expand All @@ -86,6 +87,10 @@ issize_t auth_digest_challenge_get(su_home_t *home,
"algorithm=md5", &md5,
"algorithm=md5-sess", &md5sess,
"algorithm=sha1", &sha1,
"algorithm=sha-256", &sha256,
"algorithm=sha-256-sess", &sha256sess,
"algorithm=sha-512-256", &sha512_256,
"algorithm=sha-512-256-sess", &sha512_256sess,
"stale=true", &stale,
"qop=auth", &qop_auth,
"qop=auth-int", &qop_auth_int,
Expand All @@ -97,6 +102,10 @@ issize_t auth_digest_challenge_get(su_home_t *home,
ac->ac_md5 = md5 != NULL || ac->ac_algorithm == NULL;
ac->ac_md5sess = md5sess != NULL;
ac->ac_sha1 = sha1 != NULL;
ac->ac_sha256 = sha256 != NULL;
ac->ac_sha256sess = sha256sess != NULL;
ac->ac_sha512_256 = sha512_256 != NULL;
ac->ac_sha512_256sess = sha512_256sess != NULL;
ac->ac_auth = qop_auth != NULL;
ac->ac_auth_int = qop_auth_int != NULL;

Expand Down
4 changes: 4 additions & 0 deletions libsofia-sip-ua/iptsec/sofia-sip/auth_digest.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ typedef struct {
unsigned ac_md5 : 1; /**< algorithm=MS5 (or missing) */
unsigned ac_md5sess : 1; /**< algorithm=MD5-sess */
unsigned ac_sha1 : 1; /**< algorithm=sha1 (SSA Hash) */
unsigned ac_sha256 : 1; /**< algorithm=sha-256 */
unsigned ac_sha256sess : 1; /**< algorithm=sha-256-sess */
unsigned ac_sha512_256 : 1; /**< algorithm=sha-512-256 */
unsigned ac_sha512_256sess : 1; /**< algorithm=sha-512-256-sess */
unsigned ac_auth : 1; /**< qop=auth */
unsigned ac_auth_int : 1; /**< qop=auth-int */
unsigned : 0;
Expand Down
19 changes: 19 additions & 0 deletions libsofia-sip-ua/nua/nua.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ void nua_shutdown(nua_t *nua)
*/
void nua_destroy(nua_t *nua)
{
nua_handle_t *nh, *nh_next;
enter;

if (nua) {
Expand All @@ -234,6 +235,24 @@ void nua_destroy(nua_t *nua)
#if HAVE_SMIME /* Start NRC Boston */
sm_destroy(nua->sm);
#endif /* End NRC Boston */

/* Cleanup remaining nua handles as they are su_home_new'ed and not su_home_cloned (do not belong to the nua's home)
See nh_create_handle().
*/
for (nh = nua->nua_handles; nh; nh = nh_next) {
su_home_t *nh_home = (su_home_t *)nh;
nh_next = nh->nh_next;

/* at least one handle will be found here and it is nua default handle
which is su_home_cloned (see nua_stack_init()) and therefore does not actually require to be unrefed
but it is safe to do that anyways just for sure
*/
SU_DEBUG_9(("nua(%p): found handle with refcount = "MOD_ZU". Destroying.\n", (void *)nh, su_home_refcount(nh_home)));

/* nua is about to die so we don't remove nh from nua, just unref nh */
while(!su_home_unref(nh_home));
}

nua_unref(nua);
}
}
Expand Down
10 changes: 5 additions & 5 deletions libsofia-sip-ua/nua/nua_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ void nua_application_event(nua_t *dummy, su_msg_r sumsg, nua_ee_data_t *ee)
char const *name = nua_event_name((enum nua_event_e)e->e_event) + 4;
SU_DEBUG_7(("nua(%p): event %s dropped\n", (void *)nh, name));
}
nua_handle_unref(nh);
nua_stack_unref(nua);
if (nh) nua_handle_unref_user(nh);
if (nua) nua_unref_user(nua);
return;
}

Expand All @@ -402,8 +402,8 @@ void nua_application_event(nua_t *dummy, su_msg_r sumsg, nua_ee_data_t *ee)
nua->nua_current = frame->nf_next;
}

nua_handle_unref(nh);
nua_stack_unref(nua);
if (nh) nua_handle_unref_user(nh);
if (nua) nua_unref_user(nua);
}

/** Get current request message. @NEW_1_12_4.
Expand Down Expand Up @@ -492,7 +492,7 @@ int nua_signal(nua_t *nua, nua_handle_t *nh, msg_t *msg,
if (nua == NULL)
return -1;

if (nua->nua_shutdown_started && event != nua_r_shutdown)
if (nua->nua_shutdown_started && event != nua_r_shutdown && event != nua_r_destroy && event != nua_r_handle_unref && event != nua_r_unref)
return -1;

ta_start(ta, tag, value);
Expand Down
143 changes: 125 additions & 18 deletions libsofia-sip-ua/sip/sip_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2832,8 +2832,12 @@ char const *sip_via_port(sip_via_t const *v, int *using_rport)
* typedef struct {
* sip_common_t id_common[1]; // Common fragment info
* sip_error_t *id_next; // Link to next (dummy)
* char const *id_value; // Identity
* char const *id_info; // Info param containing URL of the cert, with no '<','>'
* char const *id_value; // Identity
* char const *id_info; // Info param containing URL of the cert, with no '<','>'
* char const *id_signed_identity_digest; // Digest
* char const *id_info_alg; // Field containing alg of the cert
* char const *id_info_ppt; // Field containing PASSporT Type
* msg_param_t const *id_info_params; // Field containing extensions
* } sip_identity_t;
* @endcode
*
Expand All @@ -2850,55 +2854,137 @@ issize_t sip_identity_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen)
{
sip_identity_t *id = (sip_identity_t *)h;
char const *p = NULL, *pp = NULL, *ppp = NULL, *ie = NULL;
char *result = NULL;
char *sid = NULL, *uri = NULL, *alg = NULL, *ppt = NULL, *ext = NULL;
size_t len = 0;

id->id_value = strdup(s);
id->id_value = su_strdup(home, s);
id->id_signed_identity_digest = s;
id->id_info = NULL;

sid = strchr(s, ';');
p = strstr(s, "info=");
if (p) {
alg = strstr(s, "alg=");
ppt = strstr(s, "ppt=");

if (sid) {
*sid = '\0';
} else {
id->id_signed_identity_digest = NULL;
}

if (p) {
ie = strchr(p, ';');
pp = strchr(p, '<');
ppp = strchr(p, '>');

// allow for a spaces between "info=" and opening '<'
// extract URI from inside "<>" but allow empty - let the higher level app decide what to do about it
if (ie && pp && ppp && (pp < ppp) && (ppp < ie)) {

len = ppp - pp;
if ((result = malloc(len))) {
memcpy(result, pp + 1, len - 1);
result[len - 1] = '\0';
id->id_info = result;
}
uri = pp + 1;
uri[len - 1] = '\0';
id->id_info = uri;
}
}

if (alg) {
alg += 4;
id->id_info_alg = alg;
alg = strchr(alg, ';');
if (alg) {
*alg = '\0';
} else {
id->id_info_alg = NULL;
}
}

if (ppt) {
ext = strchr(ppt, ';');

if (ext) {
msg_param_t *params = su_alloc(home, sizeof(msg_param_t));
if (msg_params_d(home, &ext, &params) >= 0) {
id->id_info_params = params;
}
}

ppt += 4;
id->id_info_ppt = ppt;
ppt = strchr(ppt, ';');
if (ppt) {
*ppt = '\0';
}
}

return 0;
}

issize_t sip_identity_e(char b[], isize_t bsiz, sip_header_t const *h, int flags)
{
sip_identity_t const *id = (sip_identity_t *)h;
char* b0 = b, * end = b + bsiz;
sip_identity_t const* id = (sip_identity_t*)h;

if (id->id_signed_identity_digest) {
MSG_STRING_E(b, end, id->id_signed_identity_digest);
MSG_CHAR_E(b, end, ';');
}

if (id->id_info) {
MSG_STRING_E(b, end, "info=<");
MSG_STRING_E(b, end, id->id_info);
MSG_STRING_E(b, end, ">;");
}

if (id->id_info_alg) {
MSG_STRING_E(b, end, "alg=");
MSG_STRING_E(b, end, id->id_info_alg);
MSG_CHAR_E(b, end, ';');
}

if (id->id_info_ppt) {
MSG_STRING_E(b, end, "ppt=");
MSG_STRING_E(b, end, id->id_info_ppt);
/* No need to put ';' as following MSG_PARAMS_E starts from ';' */
}

if (id->id_info_params) {
MSG_PARAMS_E(b, end, id->id_info_params, flags);
}

MSG_TERM_E(b, end);

return snprintf(b, bsiz, "%s", id->id_value);
return b - b0;
}

isize_t sip_identity_dup_xtra(sip_header_t const *h, isize_t offset)
{
sip_identity_t const *id = (sip_identity_t *)h;
return offset + MSG_STRING_SIZE(id->id_value);

offset += MSG_STRING_SIZE(id->id_value);
offset += MSG_STRING_SIZE(id->id_signed_identity_digest);
offset += MSG_STRING_SIZE(id->id_info);
offset += MSG_STRING_SIZE(id->id_info_alg);
offset += MSG_STRING_SIZE(id->id_info_ppt);
MSG_PARAMS_SIZE(offset, id->id_info_params);

return offset;
}

char *sip_identity_dup_one(sip_header_t *dst, sip_header_t const *src,
char *b, isize_t xtra)
{
sip_identity_t *id = (sip_identity_t *)dst;
sip_identity_t const *o = (sip_identity_t *)src;
sip_identity_t* o_dst = dst->sh_identity;
sip_identity_t const* o_src = src->sh_identity;

MSG_STRING_DUP(b, id->id_value, o->id_value);
char* end = b + xtra;
b = msg_params_dup(&o_dst->id_info_params, o_src->id_info_params, b, xtra);
o_dst->id_value = o_src->id_value;
o_dst->id_signed_identity_digest = o_src->id_signed_identity_digest;
o_dst->id_info = o_src->id_info;
o_dst->id_info_alg = o_src->id_info_alg;
o_dst->id_info_ppt = o_src->id_info_ppt;

assert(b <= end); (void)end;

return b;
}
Expand All @@ -2909,6 +2995,27 @@ static int sip_identity_update(msg_common_t *h,
{
sip_identity_t *id = (sip_identity_t *)h;

id->id_value = strdup(value);
if (name == NULL) {
id->id_value = NULL;
id->id_signed_identity_digest = NULL;
id->id_info = NULL;
id->id_info_alg = NULL;
id->id_info_ppt = NULL;
id->id_info_params = NULL;
}
#define MATCH(s) (namelen == strlen(#s) && su_casenmatch(name, #s, strlen(#s)))
else if (MATCH(digest)) {
id->id_signed_identity_digest = value;
} else if (MATCH(uri)) {
id->id_info = value;
} else if (MATCH(alg)) {
id->id_info_alg = value;
} else if (MATCH(ppt)) {
id->id_info_ppt = value;
} else if (MATCH(value)) {
id->id_value = value;
}
#undef MATCH

return 0;
}
6 changes: 6 additions & 0 deletions libsofia-sip-ua/sip/sip_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ char const *sip_status_phrase(int status)
case 422: return sip_422_Session_timer;
case 423: return sip_423_Interval_too_brief;

case 428: return sip_428_Use_identity_header;
case 436: return sip_436_Bad_identity_info;
case 437: return sip_437_Unsupported_credential;
case 438: return sip_438_Invalid_identity_header;
case 439: return sip_439_Stale_date;

case 480: return sip_480_Temporarily_unavailable;
case 481: return sip_481_No_transaction;
case 482: return sip_482_Loop_detected;
Expand Down
Loading

0 comments on commit 5b5da8f

Please sign in to comment.