Mercurial > mplayer.hg
changeset 35894:ae62be3d8de2
Handle the severely broken headers QuickTime Streaming Server sends.
Instead of ending the header with \r\n\r\n it ends with
\r\n<4 byte MP3 header>\r\n.
And programs like wget just silently accept this without even
printing a warning!!
author | reimar |
---|---|
date | Sun, 17 Mar 2013 10:50:41 +0000 |
parents | 6065fb95813e |
children | b4047109a8bd |
files | stream/http.c |
diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/stream/http.c Sun Mar 17 10:16:49 2013 +0000 +++ b/stream/http.c Sun Mar 17 10:50:41 2013 +0000 @@ -348,6 +348,7 @@ if( http_hdr==NULL ) return -1; if( http_hdr->buffer==NULL ) return 0; // empty + if(http_hdr->buffer_size > 128*1024) return 1; if( strstr(http_hdr->buffer, "\r\n\r\n")==NULL && strstr(http_hdr->buffer, "\n\n")==NULL ) return 0; return 1; @@ -412,12 +413,12 @@ hdr_sep_len = 4; ptr = strstr( http_hdr->buffer, "\r\n\r\n" ); if( ptr==NULL ) { + hdr_sep_len = 2; ptr = strstr( http_hdr->buffer, "\n\n" ); if( ptr==NULL ) { mp_msg(MSGT_NETWORK,MSGL_ERR,"Header may be incomplete. No CRLF CRLF found.\n"); - return -1; + hdr_sep_len = 0; } - hdr_sep_len = 2; } pos_hdr_sep = ptr-http_hdr->buffer; @@ -427,7 +428,12 @@ ptr = hdr_ptr; while( *ptr!='\r' && *ptr!='\n' ) ptr++; len = ptr-hdr_ptr; - if( len==0 ) break; + if (len == 0 || !memchr(hdr_ptr, ':', len)) { + mp_msg(MSGT_NETWORK, MSGL_ERR, "Broken response header, missing ':'\n"); + pos_hdr_sep = ptr - http_hdr->buffer; + hdr_sep_len = 0; + break; + } if (len > 16 && !strncasecmp(hdr_ptr + 4, "icy-metaint:", 12)) { mp_msg(MSGT_NETWORK, MSGL_WARN, "Server sent a severely broken icy-metaint HTTP header!\n");