From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EA21C43457 for ; Tue, 20 Oct 2020 06:48:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FE90223BF for ; Tue, 20 Oct 2020 06:48:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404555AbgJTGsS convert rfc822-to-8bit (ORCPT ); Tue, 20 Oct 2020 02:48:18 -0400 Received: from mx.pao1.isc.org ([149.20.64.53]:19240 "EHLO mx.pao1.isc.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404551AbgJTGsQ (ORCPT ); Tue, 20 Oct 2020 02:48:16 -0400 Received: from zmx1.isc.org (zmx1.isc.org [149.20.0.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx.pao1.isc.org (Postfix) with ESMTPS id BA8113AB0C9 for ; Tue, 20 Oct 2020 06:48:15 +0000 (UTC) Received: from zmx1.isc.org (localhost [127.0.0.1]) by zmx1.isc.org (Postfix) with ESMTPS id 93BCA160038 for ; Tue, 20 Oct 2020 06:48:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by zmx1.isc.org (Postfix) with ESMTP id 71C07160072 for ; Tue, 20 Oct 2020 06:48:15 +0000 (UTC) Received: from zmx1.isc.org ([127.0.0.1]) by localhost (zmx1.isc.org [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id HLw_HMPILfee for ; Tue, 20 Oct 2020 06:48:15 +0000 (UTC) Received: from larwa.hq.kempniu.pl (unknown [212.180.223.213]) by zmx1.isc.org (Postfix) with ESMTPSA id D4D15160042 for ; Tue, 20 Oct 2020 06:48:14 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= To: git@vger.kernel.org Subject: [PATCH v4 1/2] merge-base, xdiff: zero out xpparam_t structures Date: Tue, 20 Oct 2020 08:48:08 +0200 Message-Id: <20201020064809.14297-2-michal@isc.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201020064809.14297-1-michal@isc.org> References: <20201015072406.4506-1-michal@isc.org> <20201020064809.14297-1-michal@isc.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org xpparam_t structures are usually zero-initialized before their specific fields are assigned to, but there are three locations in the tree where that does not happen. Add the missing memset() calls in order to make initialization of xpparam_t structures consistent tree-wide and to prevent stack garbage from being used as field values. Signed-off-by: Michał Kępień --- builtin/merge-tree.c | 1 + xdiff/xhistogram.c | 2 ++ xdiff/xpatience.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index e72714a5a8..de8520778d 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -109,6 +109,7 @@ static void show_diff(struct merge_list *entry) xdemitconf_t xecfg; xdemitcb_t ecb; + memset(&xpp, 0, sizeof(xpp)); xpp.flags = 0; memset(&xecfg, 0, sizeof(xecfg)); xecfg.ctxlen = 3; diff --git a/xdiff/xhistogram.c b/xdiff/xhistogram.c index c7b35a9667..e694bfd9e3 100644 --- a/xdiff/xhistogram.c +++ b/xdiff/xhistogram.c @@ -235,6 +235,8 @@ static int fall_back_to_classic_diff(xpparam_t const *xpp, xdfenv_t *env, int line1, int count1, int line2, int count2) { xpparam_t xpparam; + + memset(&xpparam, 0, sizeof(xpparam)); xpparam.flags = xpp->flags & ~XDF_DIFF_ALGORITHM_MASK; return xdl_fall_back_diff(env, &xpparam, diff --git a/xdiff/xpatience.c b/xdiff/xpatience.c index 3c5601b602..20699a6f60 100644 --- a/xdiff/xpatience.c +++ b/xdiff/xpatience.c @@ -318,6 +318,8 @@ static int fall_back_to_classic_diff(struct hashmap *map, int line1, int count1, int line2, int count2) { xpparam_t xpp; + + memset(&xpp, 0, sizeof(xpp)); xpp.flags = map->xpp->flags & ~XDF_DIFF_ALGORITHM_MASK; return xdl_fall_back_diff(map->env, &xpp, -- 2.28.0