]> granicus.if.org Git - rtmpdump/commitdiff
Add null termination to buffers before using strstr
authorMartin Storsjo <martin@martin.st>
Mon, 21 May 2012 15:17:29 +0000 (18:17 +0300)
committerHoward Chu <hyc@highlandsun.com>
Tue, 30 Oct 2012 16:00:40 +0000 (09:00 -0700)
librtmp/rtmp.c

index cba8b6cf32a7943ff4146e5c025aafd16b26530a..83f3247a71aeafa83f162812aca1d1b86014f843 100644 (file)
@@ -3673,7 +3673,7 @@ RTMPSockBuf_Fill(RTMPSockBuf *sb)
 
   while (1)
     {
-      nBytes = sizeof(sb->sb_buf) - sb->sb_size - (sb->sb_start - sb->sb_buf);
+      nBytes = sizeof(sb->sb_buf) - 1 - sb->sb_size - (sb->sb_start - sb->sb_buf);
 #if defined(CRYPTO) && !defined(NO_SSL)
       if (sb->sb_ssl)
        {
@@ -3852,6 +3852,7 @@ HTTP_read(RTMP *r, int fill)
     return -2;
   if (strncmp(r->m_sb.sb_start, "HTTP/1.1 200 ", 13))
     return -1;
+  r->m_sb.sb_start[r->m_sb.sb_size] = '\0';
   ptr = r->m_sb.sb_start + sizeof("HTTP/1.1 200");
   while ((ptr = strstr(ptr, "Content-"))) {
     if (!strncasecmp(ptr+8, "length:", 7)) break;