From patchwork Mon Sep 16 15:54:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 15101 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 2EDF4448C5D for ; Mon, 16 Sep 2019 19:03:21 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0AA4E688189; Mon, 16 Sep 2019 19:03:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 20F0F68815F for ; Mon, 16 Sep 2019 19:03:15 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id t3so42476wmj.1 for ; Mon, 16 Sep 2019 09:03:15 -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:mime-version :content-transfer-encoding; bh=YGc2dIjUOUxMPNhZgdd6R7jsNVJPvdwQyLogOpx4Vsc=; b=kskEdvDXfvzhzaZmu/Z0rW6CF9QFkuoHTKHDMePi3AEzBO1+53gArQqcxZytyrrmJK qUrawttNsBQ7lwjEjEiXg6V1mdACbRsFkXco+uyQP2kz06S37bw71DXwLiCS7tckGPnX LCKQQft1jjmybLb3y7nd4Kz/8yfCv2wgWsxGGkISQfNVkOrR0rOYE5ADZNn79G3eqLBc YcvTiLwJWQcOO4g9+w1KDRR+XewcLRxO4NsPbv9T+HLedtqjMSBAEb9sk1F2aL7qZ7mg Bma4BMGtJT2CqHDLmxO2Upp+ReXLYjEfdg2pY9ocz+lk0zYMnWK8EfLYGPJ6ON9wI3AX wzTg== 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:mime-version :content-transfer-encoding; bh=YGc2dIjUOUxMPNhZgdd6R7jsNVJPvdwQyLogOpx4Vsc=; b=JUL3vg5nc/TJ/X1Y4HImeeuVXsL8AMqox+4Tap87MS4wbaQJxgiCSIKDnMDMF7ovRv WskVOMdpdY53T98g8GZNKxb9OJkTwvR9Pzw/wFbnTvzKgkruCgqcbRVOltJ76e8K8O6J swrzYV8P1fHd6U981h/yynC/SFgxWLZV6ME5pu50Veo6YA2vec4Pa1fdzJh/4ofD78UQ fHI8weTPZDPj/NNQSkhW1y2gAGHc72T/wX0EeBnY6bJZ/epPVeSckyTWJ/oWkiEqQm3V lMtL3JK3E4UdMjvKnr9qe6L63iScNp5jBGNgk1iVB+51JudKnh5UCB8TFfeuPW3W2JPp w0xA== X-Gm-Message-State: APjAAAVARhQqNKIx0kG2Zb70gFA6Egcbt+DZm8fvkkC+AXCqP2TsLWsL 5wq4alD+lmg1CaLNrFthXQfrLbolKT8= X-Google-Smtp-Source: APXvYqwB/yRgD/ETtuOp4h+e/z3otC9AYJd/XqEFYzA2XPhNKJN+IMJ829DvVKjRVDKr29wgLxNRcg== X-Received: by 2002:a1c:a697:: with SMTP id p145mr209398wme.24.1568649310385; Mon, 16 Sep 2019 08:55:10 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc0f857.dynamic.kabel-deutschland.de. [188.192.248.87]) by smtp.gmail.com with ESMTPSA id d28sm48111628wrb.95.2019.09.16.08.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 08:55:09 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Sep 2019 17:54:58 +0200 Message-Id: <20190916155502.17579-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/5] avutil/encryption_info: Don't pass NULL to memcpy 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" The pointer arguments to memcpy (and several other functions of the C standard library) are not allowed to be NULL, not even when the number of bytes to copy is zero. An AVEncryptionInitInfo's data pointer is explicitly allowed to be NULL and yet av_encryption_init_info_add_side_data uncoditionally used it as a source pointer to copy from. This commit changes this so that copying is only done if the number of bytes to copy is > 0. Fixes ticket #8141 as well as a part of ticket #8150. Signed-off-by: Andreas Rheinhardt --- libavutil/encryption_info.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavutil/encryption_info.c b/libavutil/encryption_info.c index 812c704776..614791f2af 100644 --- a/libavutil/encryption_info.c +++ b/libavutil/encryption_info.c @@ -331,7 +331,8 @@ uint8_t *av_encryption_init_info_add_side_data(const AVEncryptionInitInfo *info, memcpy(cur_buffer, cur_info->key_ids[i], cur_info->key_id_size); cur_buffer += cur_info->key_id_size; } - memcpy(cur_buffer, cur_info->data, cur_info->data_size); + if (cur_info->data_size > 0) + memcpy(cur_buffer, cur_info->data, cur_info->data_size); cur_buffer += cur_info->data_size; }