Commit 7ec31734 authored by Guillaume BIENKOWSKI's avatar Guillaume BIENKOWSKI

Detect invalid URI's for remote provisioning

parent c8d65fc4
......@@ -110,14 +110,16 @@ 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://");
return linphone_remote_provisioning_load_file(lc, file_path);
} else {
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 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;
......@@ -129,14 +131,11 @@ int linphone_remote_provisioning_download_and_apply(LinphoneCore *lc, const char
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;
}
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;
}
}
......
......@@ -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 = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment