mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-29 00:59:20 +00:00
Prevent creating sip addresses which are not valid when using them
This commit is contained in:
parent
f2a4cb60d2
commit
0c4e7456d9
5 changed files with 27 additions and 4 deletions
|
|
@ -159,6 +159,13 @@ bool_t linphone_address_is_secure(const LinphoneAddress *uri){
|
|||
return sal_address_is_secure(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true if address is a routable sip address
|
||||
*/
|
||||
bool_t linphone_address_is_sip(const LinphoneAddress *uri){
|
||||
return sal_address_is_sip(uri);
|
||||
}
|
||||
|
||||
static bool_t strings_equals(const char *s1, const char *s2){
|
||||
if (s1==NULL && s2==NULL) return TRUE;
|
||||
if (s1!=NULL && s2!=NULL && strcmp(s1,s2)==0) return TRUE;
|
||||
|
|
|
|||
|
|
@ -151,6 +151,11 @@ char *sal_address_as_string(const SalAddress *addr){
|
|||
return ms_strdup(tmp);
|
||||
}
|
||||
|
||||
bool_t sal_address_is_sip(const SalAddress *addr){
|
||||
belle_sip_header_address_t* header_addr = BELLE_SIP_HEADER_ADDRESS(addr);
|
||||
return belle_sip_header_address_get_uri(header_addr) != NULL;
|
||||
}
|
||||
|
||||
char *sal_address_as_string_uri_only(const SalAddress *addr){
|
||||
belle_sip_header_address_t* header_addr = BELLE_SIP_HEADER_ADDRESS(addr);
|
||||
belle_sip_uri_t* sip_uri = belle_sip_header_address_get_uri(header_addr);
|
||||
|
|
|
|||
|
|
@ -2625,6 +2625,15 @@ void linphone_core_iterate(LinphoneCore *lc){
|
|||
}
|
||||
}
|
||||
|
||||
static LinphoneAddress* _linphone_core_destroy_addr_if_not_sip( LinphoneAddress* addr ){
|
||||
if( linphone_address_is_sip(addr) ) {
|
||||
return addr;
|
||||
} else {
|
||||
linphone_address_destroy(addr);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interpret a call destination as supplied by the user, and returns a fully qualified
|
||||
* LinphoneAddress.
|
||||
|
|
@ -2661,7 +2670,7 @@ LinphoneAddress * linphone_core_interpret_url(LinphoneCore *lc, const char *url)
|
|||
tmpurl=enumres->sip_address[0];
|
||||
uri=linphone_address_new(tmpurl);
|
||||
enum_lookup_res_free(enumres);
|
||||
return uri;
|
||||
return _linphone_core_destroy_addr_if_not_sip(uri);
|
||||
}
|
||||
/* check if we have a "sip:" or a "sips:" */
|
||||
if ( (strstr(url,"sip:")==NULL) && (strstr(url,"sips:")==NULL) ){
|
||||
|
|
@ -2672,7 +2681,7 @@ LinphoneAddress * linphone_core_interpret_url(LinphoneCore *lc, const char *url)
|
|||
uri=linphone_address_new(tmpurl);
|
||||
ms_free(tmpurl);
|
||||
if (uri){
|
||||
return uri;
|
||||
return _linphone_core_destroy_addr_if_not_sip(uri);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2688,12 +2697,12 @@ LinphoneAddress * linphone_core_interpret_url(LinphoneCore *lc, const char *url)
|
|||
linphone_proxy_config_normalize_number(proxy,url,normalized_username,
|
||||
sizeof(normalized_username));
|
||||
linphone_address_set_username(uri,normalized_username);
|
||||
return uri;
|
||||
return _linphone_core_destroy_addr_if_not_sip(uri);
|
||||
}else return NULL;
|
||||
}
|
||||
uri=linphone_address_new(url);
|
||||
if (uri!=NULL){
|
||||
return uri;
|
||||
return _linphone_core_destroy_addr_if_not_sip(uri);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -397,6 +397,7 @@ LINPHONE_PUBLIC void linphone_address_set_port(LinphoneAddress *uri, int port);
|
|||
/*remove tags, params etc... so that it is displayable to the user*/
|
||||
LINPHONE_PUBLIC void linphone_address_clean(LinphoneAddress *uri);
|
||||
LINPHONE_PUBLIC bool_t linphone_address_is_secure(const LinphoneAddress *uri);
|
||||
LINPHONE_PUBLIC bool_t linphone_address_is_sip(const LinphoneAddress *uri);
|
||||
LINPHONE_PUBLIC LinphoneTransportType linphone_address_get_transport(const LinphoneAddress *uri);
|
||||
LINPHONE_PUBLIC void linphone_address_set_transport(LinphoneAddress *uri,LinphoneTransportType type);
|
||||
LINPHONE_PUBLIC char *linphone_address_as_string(const LinphoneAddress *u);
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ void sal_address_set_transport_name(SalAddress* addr,const char* transport);
|
|||
void sal_address_set_params(SalAddress *addr, const char *params);
|
||||
void sal_address_set_uri_params(SalAddress *addr, const char *params);
|
||||
bool_t sal_address_is_ipv6(SalAddress *addr);
|
||||
bool_t sal_address_is_sip(const SalAddress *addr);
|
||||
void sal_address_set_password(SalAddress *addr, const char *passwd);
|
||||
const char *sal_address_get_password(const SalAddress *addr);
|
||||
void sal_address_set_header(SalAddress *addr, const char *header_name, const char *header_value);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue