From patchwork Thu Feb 14 20:59:02 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: 12075 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 31938448319 for ; Thu, 14 Feb 2019 22:59:11 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0D9F268A635; Thu, 14 Feb 2019 22:59:11 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it1-f195.google.com (mail-it1-f195.google.com [209.85.166.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A0BDE68A345 for ; Thu, 14 Feb 2019 22:59:04 +0200 (EET) Received: by mail-it1-f195.google.com with SMTP id v72so18031977itc.0 for ; Thu, 14 Feb 2019 12:59:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=UNqoP1oQn0ANtE9mEOJ4zjPW7PBrZpOD48olym4YMSo=; b=qv0bg0N+X5Ja6DJG7Keyz6lNhqWSTZip9Ui1NZ3Foe92g19FPk+NocueGr7oqs2R/E LnZI6LLaY9UlqhyhC4Cgnm5Ck8XVW1z3noTN5Wqb0w+ck6AGlQOS1+acuF+gVjcCIv6+ lGvMyT/ix/WE2V/YZImt8N+X0csB4m9oWSIp+2UWRO7AwQveunzm99J0ulkYPGrjQW4U OJ1O1c8J+/z2/Rhs11uwKWW7C/p2xZMmEO/+fkLpWhzkijzqfZkE+gLmbbs/9aap06Db HcbhAHsy6VLlmIJ0r6knIsX++DKHUUpx4CWlNcF9IOqr1oyxSsumT2Hm5+63Gf8Ppwvm lpRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=UNqoP1oQn0ANtE9mEOJ4zjPW7PBrZpOD48olym4YMSo=; b=Bu/jy+i2sIM/B+/3VlWvDDB8Ahlpi4Rg3Rziz0Zokwk1YyV96wmcwDCcgTsqLR1lVw 7zWcTZh3+u/hbg41Hu2vI1qa7c0sMsk7SwU7jw3Y5tYJ+3++89XrRrK00I4w1JU/2nLt +M3iVNmd80/s4KApkyUUi7AsBDRgUpOpsvZzhsGOIhkGlSJ6bTa1WqNPtN10D+dcGabi jOllaPBnXMo5ZfyozPrMcsqGhU/dnocbXOMJe0wNnSZHK+T6tNzjfu3pUG1/OHjTHjnk jROHPQPXZn5YFlQKrlocvGr9ieKqmVQ3Hoi0XISlLurwFsz/kP7ISgLvKOXOxfsKTX/4 33aw== X-Gm-Message-State: AHQUAub4ZZ7348LjjvNVQEz+CR+1aO176YkH28PVTl3knr8ozzLTzs+o DmeSrL4selIkRFU5hjP+R60fraSUfzmodCPhG/xIcQ== X-Google-Smtp-Source: AHgI3IZcokG/3rs8dB8ZNdaCvRbX02CTu6VJ0Uy7VL3tC9rwMYgoHITI0/H8pwuC9vJysB2oQCqeVZ+98a25CAirxg4= X-Received: by 2002:a24:80cb:: with SMTP id g194mr2732863itd.121.1550177943243; Thu, 14 Feb 2019 12:59:03 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a02:940e:0:0:0:0:0 with HTTP; Thu, 14 Feb 2019 12:59:02 -0800 (PST) In-Reply-To: References: From: Carl Eugen Hoyos Date: Thu, 14 Feb 2019 21:59:02 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [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" 2019-02-12 12:58 GMT+01:00, Carl Eugen Hoyos : > 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. New patch attached. Please comment, Carl Eugen From f3e4231af54b7a7664e1a2224cc1223be683f93c Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Thu, 14 Feb 2019 21:57:48 +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..4760872 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) + AV_ZERO64(out->data + out_size - 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