From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 328BE1F4B4 for ; Thu, 15 Oct 2020 07:24:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726948AbgJOHYQ convert rfc822-to-8bit (ORCPT ); Thu, 15 Oct 2020 03:24:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbgJOHYP (ORCPT ); Thu, 15 Oct 2020 03:24:15 -0400 Received: from mx.pao1.isc.org (mx.pao1.isc.org [IPv6:2001:4f8:0:2::2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE9B1C0613D2 for ; Thu, 15 Oct 2020 00:24:15 -0700 (PDT) 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 A035E3AB119 for ; Thu, 15 Oct 2020 07:24:15 +0000 (UTC) Received: from zmx1.isc.org (localhost [127.0.0.1]) by zmx1.isc.org (Postfix) with ESMTPS id 9637F16006B for ; Thu, 15 Oct 2020 07:24:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by zmx1.isc.org (Postfix) with ESMTP id 87E6D16005D for ; Thu, 15 Oct 2020 07:24: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 tRa3A3ZVjHGT for ; Thu, 15 Oct 2020 07:24:15 +0000 (UTC) Received: from larwa.hq.kempniu.pl (unknown [212.180.223.213]) by zmx1.isc.org (Postfix) with ESMTPSA id F339F16006B for ; Thu, 15 Oct 2020 07:24:14 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= To: git@vger.kernel.org Subject: [PATCH v3 1/2] merge-base, xdiff: zero out xpparam_t structures Date: Thu, 15 Oct 2020 09:24:05 +0200 Message-Id: <20201015072406.4506-2-michal@isc.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201015072406.4506-1-michal@isc.org> References: <20201012091751.19594-1-michal@isc.org> <20201015072406.4506-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