From 7b16d4b3b2a46ea3314d0a2f9140f3359750770f Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 5 Jun 2013 02:04:21 +0200 Subject: stream_cdda, stream_vcd: check read buffer size These assumed that the buffer provided with fill_buffer() was at least sector sized, instead of checking the size parameter. This is just a cleanup, since every caller made sure to align everything on sector sizes, if a stream has the sector size set. --- stream/stream_cdda.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'stream/stream_cdda.c') diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c index a99150f65d..1bec7dcc37 100644 --- a/stream/stream_cdda.c +++ b/stream/stream_cdda.c @@ -196,6 +196,9 @@ static int fill_buffer(stream_t *s, char *buffer, int max_len) int16_t *buf; int i; + if (max_len < CDIO_CD_FRAMESIZE_RAW) + return -1; + if ((p->sector < p->start_sector) || (p->sector > p->end_sector)) { s->eof = 1; return 0; -- cgit v1.2.3 From 0d5e6084aed34a9e6f48a4a2cfaf095b17acb21b Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 6 Jun 2013 20:40:02 +0200 Subject: stream: don't set EOF flag in stream implementations EOF should be set when reading more data fails. The stream implementations have nothing to say here and should behave correctly when trying to read when EOF was actually read. Even when seeking, a correct EOF flag should be guaranteed. stream_seek() (or actually stream_seek_long()) calls stream_fill_buffer() at least once, which also updates the EOF flag. --- stream/stream_cdda.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'stream/stream_cdda.c') diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c index 1bec7dcc37..c19c71d64f 100644 --- a/stream/stream_cdda.c +++ b/stream/stream_cdda.c @@ -200,7 +200,6 @@ static int fill_buffer(stream_t *s, char *buffer, int max_len) return -1; if ((p->sector < p->start_sector) || (p->sector > p->end_sector)) { - s->eof = 1; return 0; } @@ -237,7 +236,6 @@ static int seek(stream_t *s, int64_t newpos) s->pos = newpos; sec = s->pos / CDIO_CD_FRAMESIZE_RAW; if (s->pos < 0 || sec > p->end_sector) { - s->eof = 1; p->sector = p->end_sector + 1; return 0; } -- cgit v1.2.3