]> granicus.if.org Git - rtmpdump/commitdiff
Buffer more data before returning successfully from HTTP_read, if needed
authorMartin Storsjo <martin@martin.st>
Mon, 21 May 2012 15:17:30 +0000 (18:17 +0300)
committerHoward Chu <hyc@highlandsun.com>
Tue, 30 Oct 2012 16:01:01 +0000 (09:01 -0700)
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

index 83f3247a71aeafa83f162812aca1d1b86014f843..0d286660ab664d85a24c7c20b4f6430a765a4102 100644 (file)
@@ -3846,6 +3846,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)
@@ -3865,6 +3866,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--;