From patchwork Tue Feb 12 11:58:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 12051 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 65BBC44826C for ; Tue, 12 Feb 2019 13:59:01 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5253268A682; Tue, 12 Feb 2019 13:59:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it1-f179.google.com (mail-it1-f179.google.com [209.85.166.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C013D689CEA for ; Tue, 12 Feb 2019 13:58:54 +0200 (EET) Received: by mail-it1-f179.google.com with SMTP id a6so6819888itl.4 for ; Tue, 12 Feb 2019 03:58:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=X6JvrWketCaY+SxtGqYcCXGZ0vydpASn7C1F1FTC8Ws=; b=DJUSyO+lFnTVEWNBnEkW3k39p9DdVptWLBNMHI0gS7tcFTd6cqXNoKarvwzn5cYQfg cebSVSyc3SceUBBsMr5vqI7oMnLg39Y2kwEf4qua3kx7RAg/SE/hUAt6SBxOMcVdFCh/ asZdr3p60OzMTskWkGC2P0ajugwrn+GIj3HWPMf3sSW4hOuq+qLGba9faFiruGQg2xVY kiK26cc0u1KFjt7AQqWP5GHS06sOtGoRmNGC3pMdVJRD5/JfeklzPXruUG45seNL4Mkv UrwMqAPXg1TnFigg2ddupy07wkPUyujQVoqYrGv5krbwVmBNloPXhVLfLDWAtfIZYanN Nm3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=X6JvrWketCaY+SxtGqYcCXGZ0vydpASn7C1F1FTC8Ws=; b=eksqjVM80PPtXyfwZteA3ab8hVdoZ6yKoBEUqIbiR1F9DHYa9UvdaiXxsqdm0amiDm 5gJax79zHNi07IYGTq+uzzK0UYs1c+88EhFelBpZsN4UrbqV+kjWuOb6LJq8Ueht81B1 vgIT65rxkO+2YjUgr04bB+RUmEm8HcElLD5c5rPUioITkH+v5w/Fv3AkDdxEvr5ITfWO rnQ7ES6m+MoeLyZRBULSREGc3ovwcRMSIwQ6X2h5WZu/oxGMZLQGVldH/vifA7E56RtG aBqpKrY3W3J1ne2gCJF/adimeNYaEKZIzEw8e4qmsihWlBRT0rC7nY2vNrjOgQ6Dtgcc Vyfw== X-Gm-Message-State: AHQUAuYRjBECabQzxCc4ZcntB+A+bhFdmFd38te3DF9zOQJTKlynVrfF nrzHpn+5TYkECg2SbvbtCDZox2bh8HFKbSHd4jI5rA== X-Google-Smtp-Source: AHgI3IYkpj0D2Z5OccJr7edD9Hox9BO8xfwBFlvxOZAzvXXDYVHrkLmhZ5tS3fD2U06kQfOLI2jCO0S4CqtbiRGBxvI= X-Received: by 2002:a24:b64a:: with SMTP id d10mr1584793itj.149.1549972733327; Tue, 12 Feb 2019 03:58:53 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a02:454b:0:0:0:0:0 with HTTP; Tue, 12 Feb 2019 03:58:52 -0800 (PST) From: Carl Eugen Hoyos Date: Tue, 12 Feb 2019 12:58:52 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH]lavc/truehd_core: Initialize the last bytes of the output buffer 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" Hi! The output of truehd_core is currently undeterministic, the last bytes are uninitialized, valgrind protests if less than 8 bytes are initialized. I believe attached patch is simpler than calculating the necessary write size at the bottom of the function. Please comment, Carl Eugen From e824c88cc15446cc0e3f80672a38f8503333b3a7 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Tue, 12 Feb 2019 12:54:31 +0100 Subject: [PATCH] lavc/truehd_core: Initialize the last bytes of the output buffer. Avoids undeterministic output. --- libavcodec/truehd_core_bsf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/truehd_core_bsf.c b/libavcodec/truehd_core_bsf.c index be021af..a78eedc 100644 --- a/libavcodec/truehd_core_bsf.c +++ b/libavcodec/truehd_core_bsf.c @@ -117,6 +117,8 @@ static int truehd_core_filter(AVBSFContext *ctx, AVPacket *out) out->size -= reduce * 2; parity_nibble ^= out->size / 2; + if (out_size > 8) + memset(out->data + out_size - 8, 0, 8); if (have_header) { memcpy(out->data + 4, in->data + 4, 28); out->data[16 + 4] = (out->data[16 + 4] & 0x0f) | (FFMIN(s->hdr.num_substreams, 3) << 4); -- 1.7.10.4