On Thu, 26 Jul 2012, Samuel Pitoiset wrote:

When the server sends a server bandwidth packet less than 4 bytes long
we return a proper error code.

This is better, but you're still excessively wordy.

rtmp: Check the buffer length in handle_server_bw

That would be enough, right? You don't need to mention that you return a proper error code - that should always be done and only needs to be mentioned if there already was an error code but it was improper. You still don't need to mention the actual number of bytes in the commit message - if you say you check it, it's implicit that you check that there is enough bytes compared to what you read, whatever number of bytes that is. You don't need to mention what happens in this case at all - if you say you check it, it's pretty implicit that one returns an error and aborts parsing if there's not enough.

---
libavformat/rtmpproto.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index a2efe38..8d388ab 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -950,6 +950,13 @@ static int handle_server_bw(URLContext *s, RTMPPacket *pkt)
{
    RTMPContext *rt = s->priv_data;

+    if (pkt->data_size < 4) {
+        av_log(s, AV_LOG_ERROR,
+               "Server bandwidth report packet is less than 4 bytes long 
(%d)\n",
+               pkt->data_size);
+        return AVERROR_INVALIDDATA;
+    }
+

The error message can be simplified. Saying "Too short server bandwidth report packet (%d)" would be enough. When you are debugging you still find the right place in the source by looking for that message, and then you'll find everything else you need to know there.

// Martin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to