Commit 60b8ab63 authored by Simon Morlat's avatar Simon Morlat

Fix invalid read due to tester_hosts not being handled correctly

parent 91455800
...@@ -78,8 +78,7 @@ static belle_http_provider_t *prov=NULL; ...@@ -78,8 +78,7 @@ static belle_http_provider_t *prov=NULL;
static int http_before_all(void) { static int http_before_all(void) {
stack=belle_sip_stack_new(NULL); stack=belle_sip_stack_new(NULL);
if (userhostsfile) belle_sip_tester_set_dns_host_file(stack);
belle_sip_stack_set_dns_user_hosts_file(stack,userhostsfile);
prov=belle_sip_stack_create_http_provider(stack,"0.0.0.0"); prov=belle_sip_stack_create_http_provider(stack,"0.0.0.0");
if (belle_sip_tester_get_root_ca_path() != NULL) { if (belle_sip_tester_get_root_ca_path() != NULL) {
......
...@@ -272,14 +272,8 @@ int register_before_all(void) { ...@@ -272,14 +272,8 @@ int register_before_all(void) {
belle_sip_listening_point_t *lp; belle_sip_listening_point_t *lp;
stack = belle_sip_stack_new(NULL); stack = belle_sip_stack_new(NULL);
const char *client[2] = {NULL, NULL}; const char *client[2] = {NULL, NULL};
char *default_hosts = NULL;
if (!userhostsfile){ belle_sip_tester_set_dns_host_file(stack);
userhostsfile = default_hosts = bc_tester_res("tester_hosts");
}
belle_sip_stack_set_dns_user_hosts_file(stack, userhostsfile);
if (default_hosts) bc_free(default_hosts);
lp = belle_sip_stack_create_listening_point(stack, "0.0.0.0", 7060, "UDP"); lp = belle_sip_stack_create_listening_point(stack, "0.0.0.0", 7060, "UDP");
prov = belle_sip_stack_create_provider(stack, lp); prov = belle_sip_stack_create_provider(stack, lp);
......
...@@ -179,6 +179,18 @@ int belle_sip_tester_set_log_file(const char *filename) { ...@@ -179,6 +179,18 @@ int belle_sip_tester_set_log_file(const char *filename) {
return 0; return 0;
} }
void belle_sip_tester_set_dns_host_file(belle_sip_stack_t *stack){
if (userhostsfile){
belle_sip_stack_set_dns_user_hosts_file(stack, userhostsfile);
}else{
char *default_hosts = bc_tester_res("test_hosts");
if (default_hosts){
belle_sip_stack_set_dns_user_hosts_file(stack, default_hosts);
bc_free(default_hosts);
}
}
}
#if !defined(__ANDROID__) && !defined(TARGET_OS_IPHONE) && !(defined(BELLE_SIP_WINDOWS_PHONE) || defined(BELLE_SIP_WINDOWS_UNIVERSAL)) #if !defined(__ANDROID__) && !defined(TARGET_OS_IPHONE) && !(defined(BELLE_SIP_WINDOWS_PHONE) || defined(BELLE_SIP_WINDOWS_UNIVERSAL))
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include <bctoolbox/tester.h> #include <bctoolbox/tester.h>
#include "belle-sip/belle-sip.h"
#define MULTIPART_BOUNDARY "---------------------------14737809831466499882746641449" #define MULTIPART_BOUNDARY "---------------------------14737809831466499882746641449"
...@@ -58,7 +60,7 @@ void belle_sip_tester_uninit(void); ...@@ -58,7 +60,7 @@ void belle_sip_tester_uninit(void);
void belle_sip_tester_before_each(void); void belle_sip_tester_before_each(void);
void belle_sip_tester_after_each(void); void belle_sip_tester_after_each(void);
int belle_sip_tester_set_log_file(const char *filename); int belle_sip_tester_set_log_file(const char *filename);
extern const char *userhostsfile; void belle_sip_tester_set_dns_host_file(belle_sip_stack_t *stack);
#ifdef __cplusplus #ifdef __cplusplus
}; };
......
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