From patchwork Sun Feb 2 13:04:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 17660 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id B7644449F63 for ; Sun, 2 Feb 2020 15:04:46 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8EB186880D7; Sun, 2 Feb 2020 15:04:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 132BE687FE6 for ; Sun, 2 Feb 2020 15:04:40 +0200 (EET) Received: by mail-wr1-f67.google.com with SMTP id c9so14470932wrw.8 for ; Sun, 02 Feb 2020 05:04:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=0Bzm+m6i+wtE/KJm9f5lLJCr6LoQ/q1ibd0ZZPFW8Po=; b=jom1f6xSZcN9wSJepvxogZ3TgQ9QhEaS0ihkQ4RJNN+RjOpQfbmVDxDxhpEilDhEZa eGmXYUCNGoKZXjyyIFjDFFNNi/yVBtN3tBekUuC8PV3TY8k3yuEY+qLrTtR8rWJ+2pbM J56O2/fDz4n2HILHbv/zN02NOmYTYtyHGTCeCixBIiRIV4TDvu0B0Hw862Fy7wiva0Fm WOd9KH/sYTnuBhI/alzMQ5VbVWOemjZX7ewtKY6PcuLs/+TBOQDskQp9YDbolz8Y1i8x qfSN5X6tgqYOuEPWio5/fNlJRwoA5JyB0XIGepKET+iogOLj5ixe8u8AtMXepjl6gYLi YfrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=0Bzm+m6i+wtE/KJm9f5lLJCr6LoQ/q1ibd0ZZPFW8Po=; b=Kklx/nohUZoQ5Ogc20BBRdOX0y0A50hDXah0v504vTVTbfha4y46CYZN1SemN4qbif Blfd2v4MgMMLAWiP/qxS0vXDP3MF7G1G70tBdflR4Enip4WW5KGaUhbq3JMXtJoVkv0E LGBz+l7pAnzzA2h4NP+bueVIoHcb6xle29syivcm7T7iwJwlkoEmkcMe/ish+wGxUTu1 AB/oN+dKLiZI89DvMGScUWB+mIq2dxEn1h9oh+/nideqEhjkQ7nJYT67KpcFUrHJsdol eyIxS4gmlXngyCChIDzBC8drtncoavbQZD8VG/tWki/+wicTKPXBCWxvv/gW+9sKh5cM kuVQ== X-Gm-Message-State: APjAAAUslLd7A4TMI/Oj9GB8wzAyry32zt3jQ3uKEKX4qSCUuGsGrCA9 1ZprGLpYK4ViYksqrJJI249xiFMqibo= X-Google-Smtp-Source: APXvYqzbQWOtxqQNIf2LrAnnaDGomy9z6Ok5C2g6Fb7iLtgQHhGi374o+7HyQVU5i4ITJkUIPL15Zg== X-Received: by 2002:adf:8150:: with SMTP id 74mr10513786wrm.114.1580648679251; Sun, 02 Feb 2020 05:04:39 -0800 (PST) Received: from localhost.localdomain ([109.227.58.1]) by smtp.gmail.com with ESMTPSA id r6sm17946947wrp.95.2020.02.02.05.04.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Feb 2020 05:04:38 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Sun, 2 Feb 2020 14:04:27 +0100 Message-Id: <20200202130428.27689-1-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 1/2] avformat/tty: make probing strict for first 8 bytes X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Paul B Mahol --- libavformat/tty.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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) *