From patchwork Wed Jun 6 07:27:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10449777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 800266053F for ; Wed, 6 Jun 2018 07:27:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 689C7298C2 for ; Wed, 6 Jun 2018 07:27:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D9E6298D1; Wed, 6 Jun 2018 07:27:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 196B6298C2 for ; Wed, 6 Jun 2018 07:27:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932267AbeFFH1X (ORCPT ); Wed, 6 Jun 2018 03:27:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:60359 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932265AbeFFH1W (ORCPT ); Wed, 6 Jun 2018 03:27:22 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 83DC9ADF4 for ; Wed, 6 Jun 2018 07:27:20 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH 1/6] btrfs-progs: restore: Fix wrong compressed item size for decompress() Date: Wed, 6 Jun 2018 15:27:12 +0800 Message-Id: <20180606072717.28854-2-wqu@suse.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180606072717.28854-1-wqu@suse.com> References: <20180606072717.28854-1-wqu@suse.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When using decompress() in copy_one_inline(), we're passing the decompressed extent size (ram_bytes) into decompress(). However we only has @inline_item_len read out, the pending data will be uninitialized data. Thankfully, all compression methods supported have some extra data in its header, thus it won't cause real problem. Whatever fixing it is never a bad idea. Signed-off-by: Qu Wenruo --- cmds-restore.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmds-restore.c b/cmds-restore.c index 342f5cc7eabb..29a329a397c2 100644 --- a/cmds-restore.c +++ b/cmds-restore.c @@ -324,7 +324,8 @@ static int copy_one_inline(struct btrfs_root *root, int fd, return -ENOMEM; } - ret = decompress(root, buf, outbuf, len, &ram_size, compress); + ret = decompress(root, buf, outbuf, inline_item_len, &ram_size, + compress); if (ret) { free(outbuf); return ret;