From patchwork Mon Jun 15 00:01:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20381 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 BA3E6448DD8 for ; Mon, 15 Jun 2020 03:02:49 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A5D0468B6E3; Mon, 15 Jun 2020 03:02:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0637D68B671 for ; Mon, 15 Jun 2020 03:02:41 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id l10so15236570wrr.10 for ; Sun, 14 Jun 2020 17:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=peZmbTRNdq+NgStaPPwo29i1sMQkP7lEF38rnFCOK+M=; b=l5hpilasUzVkapyOyJpL6HLUq5a7wooKHZIKJ3H2Mpl9meYLEScjUpeL1pIgweeEdk +/YxTls1Od60iOW4PQgqiDJ6wq6YZtYVCp0FRZJ7fGnsM53qNccKF0RTzUxGl8AN0MDa GqQn1fFd4HNvH5BOO4VMkmbLyzgFmnpmkW3eM4OweDiBbJY+eLmTJeh8LUJi8NDORhbB 4LVlU4lXnxcP6EizsIVjgD/rpg9ayDCBJ+hoNE+EEoxiEkMqZwBLx7VRPOBTMZtgqXj3 hFzW4ONWtxip6FxGElT2j3tiPjTU9N0lv6vfPX0lQQnuvATtrlfNEZpm3pNnXfrQgLCz XPkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=peZmbTRNdq+NgStaPPwo29i1sMQkP7lEF38rnFCOK+M=; b=TgDys7Oe6mUG3kRILZW3RP8g2SxEIh4Yym3NLOe/f/R3+mTdhvsDjPRaiUzwCqd/lD Za058Jh9DlLIuN0UtVHc3oFBvhhC0piG7tPm0HLjaLjTlh+IqjcXgwrlnBYA10Kn4ipw 60EAwVv20ATrP/J1UxGkxfKJHtD5yv8UCWfCh+sf6ymr5v4zvoNDx/MQ8BaJh6UDODLl m/XMbb+h++zpOIbzvnZ5zbXFJIWayRLlwvl2gdcSo4/qis0Xm77T9a3U5a28AD5D0a7A FtZQjruQ5u7uFOLJPeU8VraN+eexJmrXwzefPgXdaA+gXJvLqragzx8uiihufNG6IU82 aMGw== X-Gm-Message-State: AOAM532+qoV5EJeBk7DEgaTSAB+ZcQb9wrZdGdhibxqc1nWTNtgdWoWN XSWScDHEEA8+nua8Hx4kZGobqMR8 X-Google-Smtp-Source: ABdhPJx+kGQW2qEH2kJ/O2+Do1KV1YoUj4xSkXUWUe2YYA2aAArcmdklXmwaUcb1e7DvGje88JB6Qg== X-Received: by 2002:adf:fc81:: with SMTP id g1mr26792817wrr.156.1592179360155; Sun, 14 Jun 2020 17:02:40 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id 5sm29512167wrr.5.2020.06.14.17.02.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 17:02:39 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Jun 2020 02:01:59 +0200 Message-Id: <20200615000204.10568-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> References: <20200614223656.21338-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 30/35] avformat/mov: Use ffio_read_size where appropriate 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- libavformat/mov.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 7c8c9bcb51..683ad49e7a 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -863,14 +863,15 @@ static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom) uint32_t frame_duration_code = 0; uint32_t channel_layout_code = 0; GetBitContext gb; + int ret; buf = av_malloc(ddts_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!buf) { return AVERROR(ENOMEM); } - if (avio_read(pb, buf, ddts_size) < ddts_size) { + if ((ret = ffio_read_size(pb, buf, ddts_size)) < 0) { av_free(buf); - return AVERROR_INVALIDDATA; + return ret; } init_get_bits(&gb, buf, 8*ddts_size); @@ -5765,12 +5766,9 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom) st = c->fc->streams[c->fc->nb_streams - 1]; sc = st->priv_data; - ret = avio_read(pb, uuid, sizeof(uuid)); - if (ret < 0) { + ret = ffio_read_size(pb, uuid, sizeof(uuid)); + if (ret < 0) return ret; - } else if (ret != sizeof(uuid)) { - return AVERROR_INVALIDDATA; - } if (!memcmp(uuid, uuid_isml_manifest, sizeof(uuid))) { uint8_t *buffer, *ptr; char *endptr; @@ -5786,13 +5784,10 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (!buffer) { return AVERROR(ENOMEM); } - ret = avio_read(pb, buffer, len); + ret = ffio_read_size(pb, buffer, len); if (ret < 0) { av_free(buffer); return ret; - } else if (ret != len) { - av_free(buffer); - return AVERROR_INVALIDDATA; } ptr = buffer; @@ -5823,13 +5818,10 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (!buffer) { return AVERROR(ENOMEM); } - ret = avio_read(pb, buffer, len); + ret = ffio_read_size(pb, buffer, len); if (ret < 0) { av_free(buffer); return ret; - } else if (ret != len) { - av_free(buffer); - return AVERROR_INVALIDDATA; } buffer[len] = '\0'; av_dict_set(&c->fc->metadata, "xmp", @@ -5973,7 +5965,7 @@ static int get_current_encryption_info(MOVContext *c, MOVEncryptionIndex **encry static int mov_read_sample_encryption_info(MOVContext *c, AVIOContext *pb, MOVStreamContext *sc, AVEncryptionInfo **sample, int use_subsamples) { - int i; + int i, ret; unsigned int subsample_count; AVSubsampleEncryptionInfo *subsamples; @@ -5987,11 +5979,11 @@ static int mov_read_sample_encryption_info(MOVContext *c, AVIOContext *pb, MOVSt return AVERROR(ENOMEM); if (sc->cenc.per_sample_iv_size != 0) { - if (avio_read(pb, (*sample)->iv, sc->cenc.per_sample_iv_size) != sc->cenc.per_sample_iv_size) { + if ((ret = ffio_read_size(pb, (*sample)->iv, sc->cenc.per_sample_iv_size)) < 0) { av_log(c->fc, AV_LOG_ERROR, "failed to read the initialization vector\n"); av_encryption_info_free(*sample); *sample = NULL; - return AVERROR_INVALIDDATA; + return ret; } } @@ -6359,9 +6351,8 @@ static int mov_read_pssh(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (!info) return AVERROR(ENOMEM); - if (avio_read(pb, info->system_id, 16) != 16) { + if ((ret = ffio_read_size(pb, info->system_id, 16)) < 0) { av_log(c->fc, AV_LOG_ERROR, "Failed to read the system id\n"); - ret = AVERROR_INVALIDDATA; goto finish; } @@ -6389,9 +6380,8 @@ static int mov_read_pssh(MOVContext *c, AVIOContext *pb, MOVAtom atom) } info->num_key_ids = i + 1; - if (avio_read(pb, info->key_ids[i], 16) != 16) { + if ((ret = ffio_read_size(pb, info->key_ids[i], 16)) < 0) { av_log(c->fc, AV_LOG_ERROR, "Failed to read the key id\n"); - ret = AVERROR_INVALIDDATA; goto finish; } }