From 8e527f61afbcb72eb7d8ae1f507765cdc2df2785 Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Mon, 21 May 2012 18:17:29 +0300 Subject: [PATCH] Add null termination to buffers before using strstr --- librtmp/rtmp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c index cba8b6c..83f3247 100644 --- a/librtmp/rtmp.c +++ b/librtmp/rtmp.c @@ -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; -- 2.11.4.GIT