---
My last patch doesn't fix the issue when the beginning of the flac is valid
(fpc->nb_headers_buffered is higher than 0) and when the rest is filled with
garbage.
How to reproduce:
$ dd if=valid.flac of=start.flac bs=8192 count=5
$ dd if=/dev/urandom of=end.flac bs=1014 count=30000
$ cat start.flac end.flac > invalid.flac
$ ./avprobe invalid.flac
libavcodec/flac_parser.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c
index bf2c118..70b9a65 100644
--- a/libavcodec/flac_parser.c
+++ b/libavcodec/flac_parser.c
@@ -565,6 +565,15 @@ static int flac_parse(AVCodecParserContext *s,
AVCodecContext *avctx,
nb_desired *
FLAC_AVG_FRAME_SIZE);
}
+ if (!av_fifo_space(fpc->fifo_buf) &&
+ av_fifo_size(fpc->fifo_buf) / FLAC_AVG_FRAME_SIZE >
+ fpc->nb_headers_buffered * 10) {
+ /* There is less than one valid flac header buffered for 10 headers
+ * buffered. Therefore the fifo is most likely filled with invalid
+ * data and the input is not a flac file. */
+ goto handle_error;
+ }
+
/* Fill the buffer. */
if (av_fifo_realloc2(fpc->fifo_buf,
(read_end - read_start) +
av_fifo_size(fpc->fifo_buf)) < 0) {
--
2.1.3
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel