mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 03:50:31 +00:00
app_confbridge: Prevent crash when publishing channel-less event.
Resolves: #1190
(cherry picked from commit efeb102507
)
This commit is contained in:
committed by
Asterisk Development Team
parent
fae0f48187
commit
a45f1e0afa
@@ -353,16 +353,28 @@ static struct ast_json *bridge_to_json(struct ast_bridge_snapshot *bridge_snapsh
|
|||||||
return json_bridge;
|
return json_bridge;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct ast_json *pack_bridge_and_channels(
|
static struct ast_json *pack_bridge_and_channel(
|
||||||
struct ast_json *json_bridge, struct ast_json *json_channels,
|
struct ast_json *json_bridge, struct ast_json *json_channel,
|
||||||
struct stasis_message * msg)
|
struct stasis_message *msg)
|
||||||
{
|
{
|
||||||
const struct timeval *tv = stasis_message_timestamp(msg);
|
const struct timeval *tv = stasis_message_timestamp(msg);
|
||||||
const char *msg_name = confbridge_event_type_to_string(stasis_message_type(msg));
|
const char *msg_name = confbridge_event_type_to_string(stasis_message_type(msg));
|
||||||
const char *fmt = ast_json_typeof(json_channels) == AST_JSON_ARRAY ?
|
|
||||||
"{s: s, s: o, s: o, s: o }" : "{s: s, s: o, s: o, s: [ o ] }";
|
|
||||||
|
|
||||||
return ast_json_pack(fmt,
|
return ast_json_pack("{s: s, s: o, s: o, s: [o*]}",
|
||||||
|
"type", msg_name,
|
||||||
|
"timestamp", ast_json_timeval(*tv, NULL),
|
||||||
|
"bridge", json_bridge,
|
||||||
|
"channels", json_channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct ast_json *pack_bridge_and_channels(
|
||||||
|
struct ast_json *json_bridge, struct ast_json *json_channels,
|
||||||
|
struct stasis_message *msg)
|
||||||
|
{
|
||||||
|
const struct timeval *tv = stasis_message_timestamp(msg);
|
||||||
|
const char *msg_name = confbridge_event_type_to_string(stasis_message_type(msg));
|
||||||
|
|
||||||
|
return ast_json_pack("{s: s, s: o, s: o, s: o}",
|
||||||
"type", msg_name,
|
"type", msg_name,
|
||||||
"timestamp", ast_json_timeval(*tv, NULL),
|
"timestamp", ast_json_timeval(*tv, NULL),
|
||||||
"bridge", json_bridge,
|
"bridge", json_bridge,
|
||||||
@@ -379,7 +391,7 @@ static struct ast_json *pack_snapshots( struct ast_bridge_snapshot *bridge_snaps
|
|||||||
json_bridge = bridge_to_json(bridge_snapshot);
|
json_bridge = bridge_to_json(bridge_snapshot);
|
||||||
json_channel = channel_to_json(channel_snapshot, conf_blob, labels_blob);
|
json_channel = channel_to_json(channel_snapshot, conf_blob, labels_blob);
|
||||||
|
|
||||||
return pack_bridge_and_channels(json_bridge, json_channel, msg);
|
return pack_bridge_and_channel(json_bridge, json_channel, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_message(const char *msg_name, char *conf_name, struct ast_json *json_object,
|
static void send_message(const char *msg_name, char *conf_name, struct ast_json *json_object,
|
||||||
|
Reference in New Issue
Block a user