avformat/rtmpproto: send proper status for response to play command

This fixes referencing the uninitialized filename variable.

Fixes ticket #9711.

Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
Marton Balint 2022-04-14 22:40:28 +02:00
parent 58aa06bea0
commit 58454749a7

View File

@ -1857,11 +1857,10 @@ static int write_begin(URLContext *s)
}
static int write_status(URLContext *s, RTMPPacket *pkt,
const char *status, const char *filename)
const char *status, const char *description, const char *details)
{
RTMPContext *rt = s->priv_data;
RTMPPacket spkt = { 0 };
char statusmsg[128];
uint8_t *pp;
int ret;
@ -1884,11 +1883,11 @@ static int write_status(URLContext *s, RTMPPacket *pkt,
ff_amf_write_field_name(&pp, "code");
ff_amf_write_string(&pp, status);
ff_amf_write_field_name(&pp, "description");
snprintf(statusmsg, sizeof(statusmsg),
"%s is now published", filename);
ff_amf_write_string(&pp, statusmsg);
ff_amf_write_string(&pp, description);
if (details) {
ff_amf_write_field_name(&pp, "details");
ff_amf_write_string(&pp, filename);
ff_amf_write_string(&pp, details);
}
ff_amf_write_object_end(&pp);
spkt.size = pp - spkt.data;
@ -1964,20 +1963,22 @@ static int send_invoke_response(URLContext *s, RTMPPacket *pkt)
pp = spkt.data;
ff_amf_write_string(&pp, "onFCPublish");
} else if (!strcmp(command, "publish")) {
char statusmsg[128];
snprintf(statusmsg, sizeof(statusmsg), "%s is now published", filename);
ret = write_begin(s);
if (ret < 0)
return ret;
// Send onStatus(NetStream.Publish.Start)
return write_status(s, pkt, "NetStream.Publish.Start",
filename);
statusmsg, filename);
} else if (!strcmp(command, "play")) {
ret = write_begin(s);
if (ret < 0)
return ret;
rt->state = STATE_SENDING;
return write_status(s, pkt, "NetStream.Play.Start",
filename);
"playing stream", NULL);
} else {
if ((ret = ff_rtmp_packet_create(&spkt, RTMP_SYSTEM_CHANNEL,
RTMP_PT_INVOKE, 0,