Commit 4cc1f028ad995562d5037a1c8c54a241956d9dbb

Stefan Sperling 2021-03-23T15:01:29

fix use of an uninitialized stat buffer during work tree status crawl found by naddy ok naddy jrick

1
2
3
4
5
6
7
8
9
10
11
12
diff --git a/lib/worktree.c b/lib/worktree.c
index 3d7fd16..da4a3d7 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -1731,6 +1731,7 @@ get_file_status(unsigned char *status, struct stat *sb,
 	unsigned char staged_status = get_staged_status(ie);
 
 	*status = GOT_STATUS_NO_CHANGE;
+	memset(sb, 0, sizeof(*sb));
 
 	/*
 	 * Whenever the caller provides a directory descriptor and a