[MPlayer-cvslog] r31914 - in trunk/stream: cache2.c stream.h
reimar
subversion at mplayerhq.hu
Tue Aug 3 18:01:40 CEST 2010
Author: reimar
Date: Tue Aug 3 18:01:40 2010
New Revision: 31914
Log:
Add sanity-check for sector size to avoid strange crashes if it is
too large.
Modified:
trunk/stream/cache2.c
trunk/stream/stream.h
Modified: trunk/stream/cache2.c
==============================================================================
--- trunk/stream/cache2.c Tue Aug 3 17:55:17 2010 (r31913)
+++ trunk/stream/cache2.c Tue Aug 3 18:01:40 2010 (r31914)
@@ -498,13 +498,19 @@ static void *ThreadProc( void *s ){
int cache_stream_fill_buffer(stream_t *s){
int len;
+ int sector_size;
if(!s->cache_pid) return stream_fill_buffer(s);
// cache_stats(s->cache_data);
if(s->pos!=((cache_vars_t*)s->cache_data)->read_filepos) mp_msg(MSGT_CACHE,MSGL_ERR,"!!! read_filepos differs!!! report this bug...\n");
+ sector_size = ((cache_vars_t*)s->cache_data)->sector_size;
+ if (sector_size > STREAM_MAX_SECTOR_SIZE) {
+ mp_msg(MSGT_CACHE, MSGL_ERR, "Sector size %i larger than maximum %i\n", sector_size, STREAM_MAX_SECTOR_SIZE);
+ sector_size = STREAM_MAX_SECTOR_SIZE;
+ }
- len=cache_read(s->cache_data,s->buffer, ((cache_vars_t*)s->cache_data)->sector_size);
+ len=cache_read(s->cache_data,s->buffer, sector_size);
//printf("cache_stream_fill_buffer->read -> %d\n",len);
if(len<=0){ s->eof=1; s->buf_pos=s->buf_len=0; return 0; }
Modified: trunk/stream/stream.h
==============================================================================
--- trunk/stream/stream.h Tue Aug 3 17:55:17 2010 (r31913)
+++ trunk/stream/stream.h Tue Aug 3 18:01:40 2010 (r31914)
@@ -54,6 +54,7 @@
#define STREAMTYPE_BLURAY 20
#define STREAM_BUFFER_SIZE 2048
+#define STREAM_MAX_SECTOR_SIZE (8*1024)
#define VCD_SECTOR_SIZE 2352
#define VCD_SECTOR_OFFS 24
@@ -162,7 +163,7 @@ typedef struct stream {
#ifdef CONFIG_NETWORKING
streaming_ctrl_t *streaming_ctrl;
#endif
- unsigned char buffer[STREAM_BUFFER_SIZE>VCD_SECTOR_SIZE?STREAM_BUFFER_SIZE:VCD_SECTOR_SIZE];
+ unsigned char buffer[STREAM_BUFFER_SIZE>STREAM_MAX_SECTOR_SIZE?STREAM_BUFFER_SIZE:STREAM_MAX_SECTOR_SIZE];
} stream_t;
#ifdef CONFIG_NETWORKING
More information about the MPlayer-cvslog
mailing list