diff mbox series

[FFmpeg-devel,1/2] avformat/tty: make probing strict for first 8 bytes

Message ID 20200202130428.27689-1-onemda@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/2] avformat/tty: make probing strict for first 8 bytes
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Paul B Mahol Feb. 2, 2020, 1:04 p.m. UTC
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavformat/tty.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavformat/tty.c b/libavformat/tty.c
index 60f7e9f87e..61e9f3e95c 100644
--- a/libavformat/tty.c
+++ b/libavformat/tty.c
@@ -53,7 +53,13 @@  static int read_probe(const AVProbeData *p)
 {
     int cnt = 0;
 
-    for (int i = 0; i < p->buf_size; i++)
+    for (int i = 0; i < 8 && i < p->buf_size; i++)
+        cnt += !!isansicode(p->buf[i]);
+
+    if (cnt != 8)
+        return 0;
+
+    for (int i = 8; i < p->buf_size; i++)
         cnt += !!isansicode(p->buf[i]);
 
     return (cnt * 100LL / p->buf_size) * (cnt > 400) *