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-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 48E811F4D7 for ; Wed, 27 Apr 2022 09:18:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230405AbiD0JUA (ORCPT ); Wed, 27 Apr 2022 05:20:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbiD0JT7 (ORCPT ); Wed, 27 Apr 2022 05:19:59 -0400 Received: from mail-vk1-xa2e.google.com (mail-vk1-xa2e.google.com [IPv6:2607:f8b0:4864:20::a2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E9AF2721BF for ; Wed, 27 Apr 2022 02:16:42 -0700 (PDT) Received: by mail-vk1-xa2e.google.com with SMTP id bc42so596768vkb.12 for ; Wed, 27 Apr 2022 02:16:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=QM6G606g+yJpD9hr0k/SFlkGrA4onUEx9o0iTpkiDCU=; b=R4UHVq2BKABIRCeUNEnIebKoFIL5Y1PwNLW2/mONOEHdhN23Toze9NH7ZtwTz8anCM TI2vHIP/EMOjCIkgP++vDKRHYhJRun5Ro8ToK6PlYkx8n2mr58+pgDOeQPCD8Tt0xhaR bGZPX5ulyzmLeoAiUzOZi8/0YiYBDzdH71wBc42GOd2OAcz03dMIuvOvoNfwQJ5ZrcgA kEDUoEHBlVBGLdYGkmvigQGoavtpIgSY4idUp4ZJj6jBJDL9BGAiWcf13KG2i7lAcFRS lOTRNCYMRxJEnUXRigUk38f1c2c+UhvEzvOOZDGlpeOnSTGSDhpn0tDdJtrmBattder5 W/qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=QM6G606g+yJpD9hr0k/SFlkGrA4onUEx9o0iTpkiDCU=; b=l/Ozx/P9x43jBblr1cBmKrnxRgk//jEOWeEhnlmQD9haG1LV6mgwq/gW6X1RLmsrV8 yRSAfhTVIJhY2Xuet91fxKWKQUp4DWuiTqHXhgwcNcZ+yPqFtE1xdaJJmIAn9WQgKEO3 RrgyJ90FZAu1mUeziEaeDUm367XroUcsIw7dgzrLPgA7s5U5T6eURiQ5WJRC5kdP6aHw FnF+CPrB5wQsfGA/e3MDezACO2ypsuG6zgN3cx7YmzKRe3xvozMU5zk/iBuhRLITSOla O3xLevBu2mgVVgELms/aSozSaZ1UghU+l6mAM8yfAs/tApSXyFjQ7VQNT1iIGg8x9mjG B9sg== X-Gm-Message-State: AOAM531fkiS5z6V2BaTyS2OILqdYtX4+y7jjoJ1NbHybzmtBaXkUYLfb Jm2ln5yQ3zk657AzveOzpenGR/gA1pI7X+0LotQ= X-Google-Smtp-Source: ABdhPJzWw0SKZDFnHvQHmcGahLWH13S2jn0kJ73+9t0j8/2MBiFwvE21gXOM9DvMfaR/FUqFxKWslsXIFoXV31GJVXU= X-Received: by 2002:a1f:38c2:0:b0:349:9667:9232 with SMTP id f185-20020a1f38c2000000b0034996679232mr8388789vka.16.1651050988584; Wed, 27 Apr 2022 02:16:28 -0700 (PDT) MIME-Version: 1.0 References: <20220427080412.37766-1-carenas@gmail.com> In-Reply-To: From: Carlo Arenas Date: Wed, 27 Apr 2022 02:16:17 -0700 Message-ID: Subject: Re: [PATCH] setup: avoid uninitialized use of is_safe in ensure_valid_ownership To: Matheus Valadares Cc: Johannes.Schindelin@gmx.de, derrickstolee@github.com, git@vger.kernel.org, gitster@pobox.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Wed, Apr 27, 2022 at 1:33 AM Matheus Valadares wrote: > > C99 standard =C2=A76.7.8 (Initialization)/21, > > If there are fewer initializers in a brace-enclosed list than there are e= lements or members of an aggregate, or fewer characters in a string literal= used to initialize an array of known size than there are elements in the a= rray, the remainder of the aggregate shall be initialized implicitly the sa= me as objects that have static storage duration. Thanks, I will include the change to remove the path initializer and add instead the is_safe one as part of my bigger change, but FWIW the following doesn't even trigger a warning with the highest level we have with neither a recent clang or gcc or even the cppcheck static analyzer, but leave and uses is_safe uninitialized. diff --git a/setup.c b/setup.c index 17c7f5fc1dc..28d008145fa 100644 --- a/setup.c +++ b/setup.c @@ -1122,7 +1122,9 @@ static int safe_directory_cb(const char *key, const char *value, void *d) static int ensure_valid_ownership(const char *path) { - struct safe_directory_data data =3D { .path =3D path, .is_safe =3D = 0 }; + struct safe_directory_data data; + + data.path =3D path; if (!git_env_bool("GIT_TEST_ASSUME_DIFFERENT_OWNER", 0) && is_path_owned_by_current_user(path)) Carlo