Handle bad NAT type info in SDP (#3552)

This commit is contained in:
Nanang Izzuddin 2023-05-15 08:20:36 +07:00 committed by GitHub
parent 56ca435999
commit d03000ac2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -1048,8 +1048,11 @@ static void update_remote_nat_type(pjsua_call *call,
const pjmedia_sdp_attr *xnat;
xnat = pjmedia_sdp_attr_find2(sdp->attr_count, sdp->attr, "X-nat", NULL);
if (xnat) {
call->rem_nat_type = (pj_stun_nat_type) (xnat->value.ptr[0] - '0');
if (xnat && xnat->value.slen > 0) {
int type = xnat->value.ptr[0] - '0';
if (type < 0 || type > PJ_STUN_NAT_TYPE_PORT_RESTRICTED)
type = PJ_STUN_NAT_TYPE_UNKNOWN;
call->rem_nat_type = (pj_stun_nat_type) type;
} else {
call->rem_nat_type = PJ_STUN_NAT_TYPE_UNKNOWN;
}