From patchwork Thu Apr 1 11:51:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 26682 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 AAB9F448C40 for ; Thu, 1 Apr 2021 15:19:39 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7AD07689246; Thu, 1 Apr 2021 15:19:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 62083688179 for ; Thu, 1 Apr 2021 15:19:32 +0300 (EEST) Received: by mail-wm1-f45.google.com with SMTP id p19so953311wmq.1 for ; Thu, 01 Apr 2021 05:19:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5QW0IHo+E+1Kv5Cv6xAXa57yfXmCe5gggNI+UPmJecc=; b=fDb16Ax4CgWQHKiVyOdP0U1AFgWYreVL11XIURL/pE/DpPLDmrJ4J+t3apSfnbs4dh O4iIswl2w3SrCzOvhaTfEbnU7ecW4QsuCCTEee5Cg32mZHV2naS1gz5A6ZI1Djk1NA72 Ey3OOZs5S7sE/Ej3YYmAsKQZBeLf7uwLGUnnGdYKzt5AswH6T8qn/eIgBqqfyf/yDxqu /l5kgahzUHYE4WXAGU697YsqYvn/UhjyURBiDSQLVkGD9yCSeLHGxigVnLcLNKkX00Ty FFVgN1DxhZYRZBWaIALPX8XW3c7S3365R33rklRQHzf9kvPs1WjhyF3nF3si6fYeHGzd VySA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=5QW0IHo+E+1Kv5Cv6xAXa57yfXmCe5gggNI+UPmJecc=; b=W+qsEopJruvzMxV+q5iWuYzySJ/yovEmiVm5j051mTUhwUruXM36hgr0CnZ0BX3C9B pyQ36SIc0Ao0itX3uUHsMwX/+6DwO1aGPvedEwQtQ+zUPXSjygRZ7ZiB9Y1c5jyCfcJS nMqMrYTDkX79lpIcW80SLrKUGCRNyMGAr2tVnrVi55RmbGksTLJGznyUYWVkmRRABY0z 5bSh3qCUgL/bXYQzjGnrQmJoBY5jQtLHVtqVLF4C9QGw66J1hDA4VfSdktSM00WDgZ3/ njollzCdXQSlyA5W3TwdFn9No+pcl2Dy0Rd0hoOPkf23PRDw75O4PGOjzG5pMe4ibC49 8UkA== X-Gm-Message-State: AOAM530fadd5hq/bFkNCwh9IQ8xMcSp1dZQewVkJ//jImmYm5em90DF2 ALaSwHHms26XM7iBdAJ+W1dTlPf+vHevqaT0 X-Google-Smtp-Source: ABdhPJy+AKLkrjQ0vuEtzK7oqYzcXWxG0crSRSjw1iPHDo8oZz2HuFXKX6x3h8pKSTIo7dqhu+zA5Q== X-Received: by 2002:a1c:1dd4:: with SMTP id d203mr7621028wmd.83.1617277870489; Thu, 01 Apr 2021 04:51:10 -0700 (PDT) Received: from localhost (host-97-187.parnet.fi. [77.234.97.187]) by smtp.gmail.com with ESMTPSA id h25sm9782576wml.32.2021.04.01.04.51.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Apr 2021 04:51:10 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Thu, 1 Apr 2021 14:51:07 +0300 Message-Id: <20210401115107.53832-2-martin@martin.st> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210401115107.53832-1-martin@martin.st> References: <20210401115107.53832-1-martin@martin.st> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] mov: Don't export unknown/unhandled metadata types as if they were UTF8 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" They can be other incompatible text encodings (such as UTF-16), or even binary data. --- libavformat/mov.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 162772f499..f539bca1f0 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -509,6 +509,14 @@ retry: av_free(str); return AVERROR_INVALIDDATA; } + } else if (data_type > 1 && data_type != 4) { + // data_type can be 0 if not set at all above. data_type 1 means + // UTF8 and 4 means "UTF8 sort". For any other type (UTF16 or e.g. + // a picture), don't return it blindly in a string that is supposed + // to be UTF8 text. + av_log(c->fc, AV_LOG_WARNING, "Skipping unhandled metadata %s of type %d\n", key, data_type); + av_free(str); + return 0; } else { int ret = ffio_read_size(pb, str, str_size); if (ret < 0) {