diff options
author | Marton Balint <cus@passwd.hu> | 2022-04-14 22:40:28 +0200 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2022-04-22 22:06:04 +0200 |
commit | 58454749a7e6b854d0120a2f58dff40a3ee7bf40 (patch) | |
tree | ea71d557983b67142f888a13f06692ee116b2dd0 | |
parent | 58aa06bea01c7d5a4ed06c502838a31d518f6a6b (diff) |
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>
-rw-r--r-- | libavformat/rtmpproto.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index f97e3c3b8e..f0ef223f05 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -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_field_name(&pp, "details"); - ff_amf_write_string(&pp, filename); + ff_amf_write_string(&pp, description); + if (details) { + ff_amf_write_field_name(&pp, "details"); + 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, |