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

Detect invalid URI's for remote provisioning

parent c8d65fc4
...@@ -110,33 +110,32 @@ static void belle_request_process_auth_requested(void *ctx, belle_sip_auth_event ...@@ -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) { 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 ){ belle_generic_uri_t *uri=belle_generic_uri_parse(remote_provisioning_uri);
// We allow for 'local remote-provisioning' in case the file is to be opened from the hard drive const char* scheme = uri ? belle_generic_uri_get_scheme(uri) : NULL;
file_path += strlen("file://");
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); 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_callbacks_t belle_request_listener={0};
belle_http_request_listener_t *listener; belle_http_request_listener_t *listener;
belle_http_request_t *request; belle_http_request_t *request;
belle_request_listener.process_response=belle_request_process_response_event; 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_auth_requested=belle_request_process_auth_requested;
belle_request_listener.process_io_error=belle_request_process_io_error; belle_request_listener.process_io_error=belle_request_process_io_error;
belle_request_listener.process_timeout=belle_request_process_timeout; belle_request_listener.process_timeout=belle_request_process_timeout;
listener = belle_http_request_listener_create_from_callbacks(&belle_request_listener, lc); 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); request=belle_http_request_create("GET",uri, NULL);
belle_http_provider_send_request(lc->http_provider, request, listener); return belle_http_provider_send_request(lc->http_provider, request, listener);
return 0; } else {
ms_error("Invalid provisioning URI [%s] (missing scheme?)",remote_provisioning_uri);
return -1;
} }
} }
......
...@@ -77,6 +77,12 @@ static void remote_provisioning_invalid(void) { ...@@ -77,6 +77,12 @@ static void remote_provisioning_invalid(void) {
linphone_core_manager_destroy(marie); 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) { static void remote_provisioning_default_values(void) {
LinphoneProxyConfig *lpc; LinphoneProxyConfig *lpc;
LinphoneCoreManager* marie = linphone_core_manager_new2("marie_remote_default_values_rc", FALSE); LinphoneCoreManager* marie = linphone_core_manager_new2("marie_remote_default_values_rc", FALSE);
...@@ -120,7 +126,8 @@ test_t remote_provisioning_tests[] = { ...@@ -120,7 +126,8 @@ test_t remote_provisioning_tests[] = {
{ "Remote provisioning invalid", remote_provisioning_invalid }, { "Remote provisioning invalid", remote_provisioning_invalid },
{ "Remote provisioning transient successful", remote_provisioning_transient }, { "Remote provisioning transient successful", remote_provisioning_transient },
{ "Remote provisioning default values", remote_provisioning_default_values }, { "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 = { 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