mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-13 12:40:17 +00:00
don't use memory after free when using naptr with mod_enum with multiple routes
This commit is contained in:
parent
a83fde3543
commit
5c07c3eb03
@ -368,7 +368,7 @@ static void parse_naptr(const ldns_rr *naptr, const char *number, enum_record_t
|
|||||||
int proceed = 0, ovector[30];
|
int proceed = 0, ovector[30];
|
||||||
char *substituted = NULL;
|
char *substituted = NULL;
|
||||||
char *substituted_2 = NULL;
|
char *substituted_2 = NULL;
|
||||||
char *uri;
|
char *orig_uri;
|
||||||
char *uri_expanded = NULL;
|
char *uri_expanded = NULL;
|
||||||
enum_route_t *route;
|
enum_route_t *route;
|
||||||
int supported = 0;
|
int supported = 0;
|
||||||
@ -385,13 +385,15 @@ static void parse_naptr(const ldns_rr *naptr, const char *number, enum_record_t
|
|||||||
memset(substituted, 0, len);
|
memset(substituted, 0, len);
|
||||||
|
|
||||||
switch_perform_substitution(re, proceed, replace, number, substituted, len, ovector);
|
switch_perform_substitution(re, proceed, replace, number, substituted, len, ovector);
|
||||||
uri = substituted;
|
orig_uri = substituted;
|
||||||
} else {
|
} else {
|
||||||
uri = replace;
|
orig_uri = replace;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_mutex_lock(MUTEX);
|
switch_mutex_lock(MUTEX);
|
||||||
for (route = globals.route_order; route; route = route->next) {
|
for (route = globals.route_order; route; route = route->next) {
|
||||||
|
char *uri = orig_uri;
|
||||||
|
|
||||||
if (strcasecmp(service, route->service)) {
|
if (strcasecmp(service, route->service)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -437,7 +439,7 @@ static void parse_naptr(const ldns_rr *naptr, const char *number, enum_record_t
|
|||||||
switch_mutex_unlock(MUTEX);
|
switch_mutex_unlock(MUTEX);
|
||||||
|
|
||||||
if (!supported) {
|
if (!supported) {
|
||||||
add_result(results, order, preference, service, uri, 0);
|
add_result(results, order, preference, service, orig_uri, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_safe_free(substituted);
|
switch_safe_free(substituted);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user