Commit 95b256f4 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Fixed crash if log upload server URL is invalid

parent 3f7ec0eb
......@@ -1019,6 +1019,16 @@ void linphone_core_upload_log_collection(LinphoneCore *core) {
belle_http_request_t *req;
char *name;
uri = belle_generic_uri_parse(linphone_core_get_log_collection_upload_server_url(core));
if (uri == NULL || !belle_generic_uri_get_host(uri)) {
ms_error("Invalid log upload server URL: %s", linphone_core_get_log_collection_upload_server_url(core));
linphone_core_notify_log_collection_upload_state_changed(core, LinphoneCoreLogCollectionUploadStateNotDelivered, "Invalid log upload server URL");
if (uri) {
belle_sip_object_unref(uri);
}
return;
}
core->log_collection_upload_information = linphone_core_create_content(core);
#ifdef HAVE_ZLIB
linphone_content_set_type(core->log_collection_upload_information, "application");
......@@ -1036,10 +1046,13 @@ void linphone_core_upload_log_collection(LinphoneCore *core) {
core->log_collection_upload_information = NULL;
ms_error("prepare_log_collection_file_to_upload(): error.");
linphone_core_notify_log_collection_upload_state_changed(core, LinphoneCoreLogCollectionUploadStateNotDelivered, "Error while preparing log collection upload");
if (uri) {
belle_sip_object_unref(uri);
}
return;
}
linphone_content_set_size(core->log_collection_upload_information, get_size_of_file_to_upload(name));
uri = belle_generic_uri_parse(linphone_core_get_log_collection_upload_server_url(core));
req = belle_http_request_create("POST", uri, NULL, NULL, NULL);
cbs.process_response = process_response_from_post_file_log_collection;
cbs.process_io_error = process_io_error_upload_log_collection;
......
......@@ -295,6 +295,22 @@ static void logCollectionUploadStateChangedCb(LinphoneCore *lc, LinphoneCoreLogC
break;
}
}
static void upload_wrong_url(void) {
LinphoneCoreManager* marie = setup(LinphoneLogCollectionEnabled);
LinphoneCoreCbs *cbs = linphone_factory_create_core_cbs(linphone_factory_get());
linphone_core_cbs_set_log_collection_upload_state_changed(cbs, logCollectionUploadStateChangedCb);
linphone_core_add_callbacks(marie->lc, cbs);
linphone_core_cbs_unref(cbs);
linphone_core_set_log_collection_upload_server_url(marie->lc,"text");
linphone_core_upload_log_collection(marie->lc);
BC_ASSERT_TRUE(wait_for_until(marie->lc,marie->lc,&marie->stat.number_of_LinphoneCoreLogCollectionUploadStateNotDelivered, 1, 10000));
collect_cleanup(marie);
}
static void upload_collected_traces(void) {
if (transport_supported(LinphoneTransportTls)) {
LinphoneCoreManager* marie = setup(LinphoneLogCollectionEnabled);
......@@ -328,6 +344,7 @@ test_t log_collection_tests[] = {
TEST_NO_TAG("Collect files filled when enabled", collect_files_filled),
TEST_NO_TAG("Logs collected into small file", collect_files_small_size),
TEST_NO_TAG("Logs collected when decreasing max size", collect_files_changing_size),
TEST_NO_TAG("Log upload to wrong URL", upload_wrong_url),
TEST_NO_TAG("Upload collected traces", upload_collected_traces)
};
......
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