[rtmpdump] [PATCH 2/4] Buffer more data before returning successfully from HTTP_read, if needed
Martin Storsjo
martin at martin.st
Mon May 21 17:17:30 CEST 2012
This fixes issues if the http header and the payload data
are sent in separate packets (as they normally are), and the
buffer contains the full header but none of the payload.
---
librtmp/rtmp.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
index d667fb4..4afcecf 100644
--- a/librtmp/rtmp.c
+++ b/librtmp/rtmp.c
@@ -3731,6 +3731,7 @@ HTTP_read(RTMP *r, int fill)
char *ptr;
int hlen;
+restart:
if (fill)
RTMPSockBuf_Fill(&r->m_sb);
if (r->m_sb.sb_size < 144)
@@ -3750,6 +3751,12 @@ HTTP_read(RTMP *r, int fill)
if (!ptr)
return -1;
ptr += 4;
+ if (ptr + (r->m_clientID.av_val ? 1 : hlen) > r->m_sb.sb_start + r->m_sb.sb_size)
+ {
+ if (fill)
+ goto restart;
+ return -2;
+ }
r->m_sb.sb_size -= ptr - r->m_sb.sb_start;
r->m_sb.sb_start = ptr;
r->m_unackd--;
--
1.7.9.4
More information about the rtmpdump
mailing list