Mercurial > mplayer.hg
comparison stream/cache2.c @ 31835:73f85fc599e0
Add sanity-check for sector size to avoid strange crashes if it is
too large.
author | reimar |
---|---|
date | Tue, 03 Aug 2010 16:01:40 +0000 |
parents | ba740e64ba01 |
children | f1e3d7471ac8 |
comparison
equal
deleted
inserted
replaced
31834:64ba1daa147a | 31835:73f85fc599e0 |
---|---|
496 #endif | 496 #endif |
497 #endif | 497 #endif |
498 | 498 |
499 int cache_stream_fill_buffer(stream_t *s){ | 499 int cache_stream_fill_buffer(stream_t *s){ |
500 int len; | 500 int len; |
501 int sector_size; | |
501 if(!s->cache_pid) return stream_fill_buffer(s); | 502 if(!s->cache_pid) return stream_fill_buffer(s); |
502 | 503 |
503 // cache_stats(s->cache_data); | 504 // cache_stats(s->cache_data); |
504 | 505 |
505 if(s->pos!=((cache_vars_t*)s->cache_data)->read_filepos) mp_msg(MSGT_CACHE,MSGL_ERR,"!!! read_filepos differs!!! report this bug...\n"); | 506 if(s->pos!=((cache_vars_t*)s->cache_data)->read_filepos) mp_msg(MSGT_CACHE,MSGL_ERR,"!!! read_filepos differs!!! report this bug...\n"); |
506 | 507 sector_size = ((cache_vars_t*)s->cache_data)->sector_size; |
507 len=cache_read(s->cache_data,s->buffer, ((cache_vars_t*)s->cache_data)->sector_size); | 508 if (sector_size > STREAM_MAX_SECTOR_SIZE) { |
509 mp_msg(MSGT_CACHE, MSGL_ERR, "Sector size %i larger than maximum %i\n", sector_size, STREAM_MAX_SECTOR_SIZE); | |
510 sector_size = STREAM_MAX_SECTOR_SIZE; | |
511 } | |
512 | |
513 len=cache_read(s->cache_data,s->buffer, sector_size); | |
508 //printf("cache_stream_fill_buffer->read -> %d\n",len); | 514 //printf("cache_stream_fill_buffer->read -> %d\n",len); |
509 | 515 |
510 if(len<=0){ s->eof=1; s->buf_pos=s->buf_len=0; return 0; } | 516 if(len<=0){ s->eof=1; s->buf_pos=s->buf_len=0; return 0; } |
511 s->eof=0; | 517 s->eof=0; |
512 s->buf_pos=0; | 518 s->buf_pos=0; |