mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-03 11:49:31 +00:00
Detect invalid URI's for remote provisioning
This commit is contained in:
parent
c8d65fc4ec
commit
7ec3173462
3 changed files with 26 additions and 17 deletions
|
|
@ -110,33 +110,32 @@ static void belle_request_process_auth_requested(void *ctx, belle_sip_auth_event
|
|||
}
|
||||
|
||||
int linphone_remote_provisioning_download_and_apply(LinphoneCore *lc, const char *remote_provisioning_uri) {
|
||||
const char* file_path = strstr(remote_provisioning_uri, "file://");
|
||||
|
||||
if( file_path == remote_provisioning_uri ){
|
||||
// We allow for 'local remote-provisioning' in case the file is to be opened from the hard drive
|
||||
file_path += strlen("file://");
|
||||
belle_generic_uri_t *uri=belle_generic_uri_parse(remote_provisioning_uri);
|
||||
const char* scheme = uri ? belle_generic_uri_get_scheme(uri) : NULL;
|
||||
|
||||
if( scheme && (strcmp(scheme,"file") == 0) ){
|
||||
// We allow for 'local remote-provisioning' in case the file is to be opened from the hard drive.
|
||||
const char* file_path = remote_provisioning_uri + strlen("file://"); // skip scheme
|
||||
return linphone_remote_provisioning_load_file(lc, file_path);
|
||||
} else {
|
||||
belle_generic_uri_t *uri=belle_generic_uri_parse(remote_provisioning_uri);
|
||||
|
||||
} else if( scheme && strncmp(scheme, "http", 4) == 0 ) {
|
||||
belle_http_request_listener_callbacks_t belle_request_listener={0};
|
||||
belle_http_request_listener_t *listener;
|
||||
belle_http_request_t *request;
|
||||
|
||||
|
||||
belle_request_listener.process_response=belle_request_process_response_event;
|
||||
belle_request_listener.process_auth_requested=belle_request_process_auth_requested;
|
||||
belle_request_listener.process_io_error=belle_request_process_io_error;
|
||||
belle_request_listener.process_timeout=belle_request_process_timeout;
|
||||
|
||||
listener = belle_http_request_listener_create_from_callbacks(&belle_request_listener, lc);
|
||||
|
||||
|
||||
if (uri==NULL) {
|
||||
belle_sip_error("Invalid provisioning URI [%s]",remote_provisioning_uri);
|
||||
return -1;
|
||||
}
|
||||
listener = belle_http_request_listener_create_from_callbacks(&belle_request_listener, lc);
|
||||
|
||||
request=belle_http_request_create("GET",uri, NULL);
|
||||
belle_http_provider_send_request(lc->http_provider, request, listener);
|
||||
return 0;
|
||||
return belle_http_provider_send_request(lc->http_provider, request, listener);
|
||||
} else {
|
||||
ms_error("Invalid provisioning URI [%s] (missing scheme?)",remote_provisioning_uri);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
3
tester/rcfiles/marie_remote_invalid_uri_rc
Normal file
3
tester/rcfiles/marie_remote_invalid_uri_rc
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[misc]
|
||||
config-uri=/tmp/lol
|
||||
|
||||
|
|
@ -77,6 +77,12 @@ static void remote_provisioning_invalid(void) {
|
|||
linphone_core_manager_destroy(marie);
|
||||
}
|
||||
|
||||
static void remote_provisioning_invalid_uri(void) {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new2("marie_remote_invalid_uri_rc", FALSE);
|
||||
CU_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphoneConfiguringFailed,1));
|
||||
linphone_core_manager_destroy(marie);
|
||||
}
|
||||
|
||||
static void remote_provisioning_default_values(void) {
|
||||
LinphoneProxyConfig *lpc;
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new2("marie_remote_default_values_rc", FALSE);
|
||||
|
|
@ -120,7 +126,8 @@ test_t remote_provisioning_tests[] = {
|
|||
{ "Remote provisioning invalid", remote_provisioning_invalid },
|
||||
{ "Remote provisioning transient successful", remote_provisioning_transient },
|
||||
{ "Remote provisioning default values", remote_provisioning_default_values },
|
||||
{ "Remote provisioning from file", remote_provisioning_file }
|
||||
{ "Remote provisioning from file", remote_provisioning_file },
|
||||
{ "Remote provisioning invalid URI", remote_provisioning_invalid_uri }
|
||||
};
|
||||
|
||||
test_suite_t remote_provisioning_test_suite = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue