[MPlayer-cvslog] r35988 - trunk/stream/http.c

reimar subversion at mplayerhq.hu
Sun Mar 17 11:50:41 CET 2013


Author: reimar
Date: Sun Mar 17 11:50:41 2013
New Revision: 35988

Log:
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!!

Modified:
   trunk/stream/http.c

Modified: trunk/stream/http.c
==============================================================================
--- trunk/stream/http.c	Sun Mar 17 11:16:49 2013	(r35987)
+++ trunk/stream/http.c	Sun Mar 17 11:50:41 2013	(r35988)
@@ -348,6 +348,7 @@ http_is_header_entire( HTTP_header_t *ht
 	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 @@ http_response_parse( HTTP_header_t *http
 	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 @@ http_response_parse( HTTP_header_t *http
 		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");


More information about the MPlayer-cvslog mailing list