mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-22 20:56:39 +00:00
Merge changes for AST-2014-010, AST-2014-009
git-svn-id: https://origsvn.digium.com/svn/asterisk/tags/12.5.1@423448 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -366,7 +366,7 @@ static void subscription_persistence_remove(struct ast_sip_subscription *sub)
|
||||
|
||||
static struct ast_sip_subscription_handler *find_sub_handler_for_event_name(const char *event_name);
|
||||
static struct ast_sip_pubsub_body_generator *find_body_generator(char accept[AST_SIP_MAX_ACCEPT][64],
|
||||
size_t num_accept);
|
||||
size_t num_accept, const char *body_type);
|
||||
|
||||
/*! \brief Retrieve a handler using the Event header of an rdata message */
|
||||
static struct ast_sip_subscription_handler *subscription_get_handler_from_rdata(pjsip_rx_data *rdata)
|
||||
@@ -414,7 +414,7 @@ static struct ast_sip_pubsub_body_generator *subscription_get_generator_from_rda
|
||||
num_accept_headers = 1;
|
||||
}
|
||||
|
||||
return find_body_generator(accept, num_accept_headers);
|
||||
return find_body_generator(accept, num_accept_headers, handler->body_type);
|
||||
}
|
||||
|
||||
/*! \brief Callback function to perform the actual recreation of a subscription */
|
||||
@@ -1092,7 +1092,7 @@ static struct ast_sip_pubsub_body_generator *find_body_generator_accept(const ch
|
||||
}
|
||||
|
||||
static struct ast_sip_pubsub_body_generator *find_body_generator(char accept[AST_SIP_MAX_ACCEPT][64],
|
||||
size_t num_accept)
|
||||
size_t num_accept, const char *body_type)
|
||||
{
|
||||
int i;
|
||||
struct ast_sip_pubsub_body_generator *generator = NULL;
|
||||
@@ -1101,6 +1101,12 @@ static struct ast_sip_pubsub_body_generator *find_body_generator(char accept[AST
|
||||
generator = find_body_generator_accept(accept[i]);
|
||||
if (generator) {
|
||||
ast_debug(3, "Body generator %p found for accept type %s\n", generator, accept[i]);
|
||||
if (strcmp(generator->body_type, body_type)) {
|
||||
ast_log(LOG_WARNING, "Body generator '%s/%s'(%p) does not accept the type of data this event generates\n",
|
||||
generator->type, generator->subtype, generator);
|
||||
generator = NULL;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
ast_debug(3, "No body generator found for accept type %s\n", accept[i]);
|
||||
@@ -1511,7 +1517,7 @@ const char *ast_sip_subscription_get_body_subtype(struct ast_sip_subscription *s
|
||||
}
|
||||
|
||||
int ast_sip_pubsub_generate_body_content(const char *type, const char *subtype,
|
||||
void *data, struct ast_str **str)
|
||||
struct ast_sip_body_data *data, struct ast_str **str)
|
||||
{
|
||||
struct ast_sip_pubsub_body_supplement *supplement;
|
||||
struct ast_sip_pubsub_body_generator *generator;
|
||||
@@ -1525,14 +1531,19 @@ int ast_sip_pubsub_generate_body_content(const char *type, const char *subtype,
|
||||
return -1;
|
||||
}
|
||||
|
||||
body = generator->allocate_body(data);
|
||||
if (strcmp(data->body_type, generator->body_type)) {
|
||||
ast_log(LOG_WARNING, "Body generator does not accept the type of data provided\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
body = generator->allocate_body(data->body_data);
|
||||
if (!body) {
|
||||
ast_log(LOG_WARNING, "Unable to allocate a NOTIFY body of type %s/%s\n",
|
||||
type, subtype);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (generator->generate_body_content(body, data)) {
|
||||
if (generator->generate_body_content(body, data->body_data)) {
|
||||
res = -1;
|
||||
goto end;
|
||||
}
|
||||
@@ -1541,7 +1552,7 @@ int ast_sip_pubsub_generate_body_content(const char *type, const char *subtype,
|
||||
AST_RWLIST_TRAVERSE(&body_supplements, supplement, list) {
|
||||
if (!strcmp(generator->type, supplement->type) &&
|
||||
!strcmp(generator->subtype, supplement->subtype)) {
|
||||
res = supplement->supplement_body(body, data);
|
||||
res = supplement->supplement_body(body, data->body_data);
|
||||
if (res) {
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user