[PATCH] setup: avoid uninitialized use of is_safe in ensure_valid_ownership

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



8959555cee7 (setup_git_directory(): add an owner check for the top-level
directory, 2022-03-02) adds this member as part of a newly created
structure that then gets initialized during the callback, but bb50ec3cc30
(setup: fix safe.directory key not being checked, 2022-04-13) add a
quick exit from the callback that avoids this initialization unless the
callback is called with the relevant key.

This leads to this variable not being initialized UNLESS the global config
has at least one key for safe.directory, so instead initialize it in the
caller.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@xxxxxxxxx>
---
 setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.c b/setup.c
index a7b36f3ffbf..17c7f5fc1dc 100644
--- a/setup.c
+++ b/setup.c
@@ -1122,7 +1122,7 @@ 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 = { .path = path };
+	struct safe_directory_data data = { .path = path, .is_safe = 0 };
 
 	if (!git_env_bool("GIT_TEST_ASSUME_DIFFERENT_OWNER", 0) &&
 	    is_path_owned_by_current_user(path))
-- 
2.36.0.266.g59f845bde02




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux