Changeset 99f3e5493956c0cc4df7416df2da23cc7d4fd55d
- Timestamp:
- 11/07/02 17:54:39
(6 years ago)
- Author:
- Gildas Bazin <gbazin@videolan.org>
- git-committer:
- Gildas Bazin <gbazin@videolan.org> 1036688079 +0000
- git-parent:
[85071f3419dec4837538a25f0ab8853cd6ddf531]
- git-author:
- Gildas Bazin <gbazin@videolan.org> 1036688079 +0000
- Message:
* modules/access/http.c: don't crash, but complain on non http/1.x streams.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r0e24796 |
r99f3e54 |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 2001, 2002 VideoLAN |
|---|
| 5 | | * $Id: http.c,v 1.5 2002/10/07 21:58:40 massiot Exp $ |
|---|
| | 5 | * $Id: http.c,v 1.6 2002/11/07 16:54:39 gbazin Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Christophe Massiot <massiot@via.ecp.fr> |
|---|
| … | … | |
| 97 | 97 | char psz_buffer[256]; |
|---|
| 98 | 98 | byte_t * psz_parser; |
|---|
| 99 | | int i_returncode, i; |
|---|
| | 99 | int i_returncode, i, i_size; |
|---|
| 100 | 100 | char * psz_return_alpha; |
|---|
| 101 | 101 | |
|---|
| … | … | |
| 161 | 161 | |
|---|
| 162 | 162 | /* get the returncode */ |
|---|
| 163 | | if( input_Peek( p_input, &psz_parser, MAX_LINE ) <= 0 ) |
|---|
| | 163 | if( (i_size = input_Peek( p_input, &psz_parser, MAX_LINE )) <= 0 ) |
|---|
| 164 | 164 | { |
|---|
| 165 | 165 | msg_Err( p_input, "not enough data" ); |
|---|
| … | … | |
| 168 | 168 | } |
|---|
| 169 | 169 | |
|---|
| 170 | | if( !strncmp( psz_parser, "HTTP/1.", |
|---|
| 171 | | strlen("HTTP/1.") ) ) |
|---|
| 172 | | { |
|---|
| 173 | | psz_parser += strlen("HTTP 1.") + 2; |
|---|
| | 170 | if( (i_size >= sizeof("HTTP/1.") + 1 ) && |
|---|
| | 171 | !strncmp( psz_parser, "HTTP/1.", sizeof("HTTP/1.") - 1 ) ) |
|---|
| | 172 | { |
|---|
| | 173 | psz_parser += sizeof("HTTP/1.") + 1; |
|---|
| 174 | 174 | i_returncode = atoi( (char*)psz_parser ); |
|---|
| 175 | 175 | msg_Dbg( p_input, "HTTP server replied: %i", i_returncode ); |
|---|
| 176 | 176 | psz_parser += 4; |
|---|
| 177 | | for ( i = 0; psz_parser[i] != '\r' || psz_parser[i+1] != '\n'; i++ ) |
|---|
| | 177 | i_size -= (sizeof("HTTP/1.") + 5); |
|---|
| | 178 | for ( i = 0; (i < i_size -1) && ((psz_parser[i] != '\r') || |
|---|
| | 179 | (psz_parser[i+1] != '\n')); i++ ) |
|---|
| 178 | 180 | { |
|---|
| 179 | 181 | ; |
|---|
| 180 | 182 | } |
|---|
| | 183 | /* check we actually parsed something */ |
|---|
| | 184 | if ( (i == i_size - 1) && (psz_parser[i+1] != '\n') ) |
|---|
| | 185 | { |
|---|
| | 186 | msg_Err( p_input, "stream not compliant with HTTP/1.x" ); |
|---|
| | 187 | return -1; |
|---|
| | 188 | } |
|---|
| | 189 | |
|---|
| 181 | 190 | psz_return_alpha = malloc( i + 1 ); |
|---|
| 182 | 191 | memcpy( psz_return_alpha, psz_parser, i ); |
|---|
| … | … | |
| 188 | 197 | return -1; |
|---|
| 189 | 198 | } |
|---|
| 190 | | |
|---|
| | 199 | |
|---|
| 191 | 200 | if ( i_returncode >= 400 ) /* something is wrong */ |
|---|
| 192 | 201 | { |
|---|