From patchwork Sat May 30 16:05:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 19997 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 62B5344A6AD for ; Sat, 30 May 2020 19:06:31 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4FA9368AFEB; Sat, 30 May 2020 19:06:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 93E7B68AF6D for ; Sat, 30 May 2020 19:06:19 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id c71so6672756wmd.5 for ; Sat, 30 May 2020 09:06:19 -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=g+qUsPKpzdfyWLDONR49j3TXTwJjKF+DmOHB09tb/vo=; b=ThHsBQxz+duwCFBPk70PJqiTmglekR9sADgQ5yfMN8Q9hNxyms905nA8L7F0rZT+aG mj4JWXfNGjYVdRHwg0c29Jf07yBmN5uGlzh80zKktXvckE5JoiVqN5UrEvvhpNMS0eOr AdwtFOXMPoeVDwbtrI3hlr3AqWFcOAJjbWQ/2/Vg7ctdUG4/90wl0/rRRDeOyH6pJj6T mxCfofEuVQ8kBZIP+2N+tLgkNGyt6AtafNt1lJqcx9N3r2AzemEhu7GJW+KO6Z0wtdrV xaIYm10KNk7bHFguyBfN/EwUDeTLaQSu9eiNUFJx+0S9X3hswQAr1AudAWOwUFfjhOg9 sSGA== 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=g+qUsPKpzdfyWLDONR49j3TXTwJjKF+DmOHB09tb/vo=; b=iamcwJhLSCPRVxK9sAR2jdg2bb5EFKrMrvfh3mbSMhZJRz12fsKeL3aCG4KTxtWxkB dxiiqwFiqIggTHFNB8Pfxn8Fm3JFzxWSd7dWGb6qN1T0QBIbMP3p/FqIeQy6D56z2ZhE qO6z2DxCuX9WnZAs0YrBaEawifJHOXhIiJfHMy3DOW1DlB1hZTC6DcXy/hvcgUcx806N ulBpYr3OVMhjZfRPB3AGJ63h7d2sqjpQ61F9xrgrhqZppTaEWHx1Qxq7PAKWOy762W/F RKT2Sy4NoDAWn/COXymjZqWzPIVvn9NrPqSmjQI8T7hSw5DlAcqOXbCrCy6eV2j9JlqB V48Q== X-Gm-Message-State: AOAM531ku5BjEt/NZZQQt7z0wVk93IwHzJ5ISTEluxDbQCtPWMjsmfLA a1RcEh/z6USpiNDNWtVmvbPirdxt X-Google-Smtp-Source: ABdhPJxzK15C+CQ+qrGr4ghhc/Jta75X2rmncEpdox8PHyuUicfpeIdI32A4hN26xxpNzScO7MUJhQ== X-Received: by 2002:a1c:230a:: with SMTP id j10mr13468815wmj.124.1590854778703; Sat, 30 May 2020 09:06:18 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id v27sm15186517wrv.81.2020.05.30.09.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 May 2020 09:06:18 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 30 May 2020 18:05:13 +0200 Message-Id: <20200530160541.29517-8-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200530160541.29517-1-andreas.rheinhardt@gmail.com> References: <20200530160541.29517-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/36] avcodec/vp9_superframe_split_bsf: Improve returned error message 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" If a parsed frame size happens to be so big that it is negative (as an int), the size in the error message would be negative which is nonsense in light of the fact that the size field is an unsigned value in the standard. Change this and also change the type of the variable to unsigned. Also return AVERROR_INVALIDDATA and not AVERROR(EINVAL) in this case as this is clearly invalid data. Signed-off-by: Andreas Rheinhardt --- libavcodec/vp9_superframe_split_bsf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/vp9_superframe_split_bsf.c b/libavcodec/vp9_superframe_split_bsf.c index 6ebecfa8ae..df5b964414 100644 --- a/libavcodec/vp9_superframe_split_bsf.c +++ b/libavcodec/vp9_superframe_split_bsf.c @@ -70,15 +70,15 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, AVPacket *out) nb_frames * length_size); for (i = 0; i < nb_frames; i++) { - int frame_size = 0; + unsigned frame_size = 0; for (j = 0; j < length_size; j++) frame_size |= bytestream2_get_byte(&bc) << (j * 8); total_size += frame_size; - if (frame_size <= 0 || total_size > in->size - idx_size) { + if (!frame_size || total_size > in->size - idx_size) { av_log(ctx, AV_LOG_ERROR, - "Invalid frame size in a superframe: %d\n", frame_size); - ret = AVERROR(EINVAL); + "Invalid frame size in a superframe: %u\n", frame_size); + ret = AVERROR_INVALIDDATA; goto fail; } s->sizes[i] = frame_size;