Commit 9fac8b78347b5830bc1068efd804fa25ebc9ec1e

Patrick Steinhardt 2019-07-21T15:08:22

config_file: do not refresh read-only backends If calling `config_refresh` on a read-only configuration file backend, then we will segfault when comparing the timestamp of the file due to `path` being uninitialized. As a read-only snapshot should not be refreshed anyway and stay consistent, we can simply return early when calling `config_refresh` on a read-only snapshot.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/src/config_file.c b/src/config_file.c
index a15dba0..1b674b1 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -231,8 +231,10 @@ static int config_refresh(git_config_backend *cfg)
 	git_config_entries *entries = NULL;
 	int error, modified;
 
-	error = config_is_modified(&modified, &b->file);
-	if (error < 0 && error != GIT_ENOTFOUND)
+	if (cfg->readonly)
+		return 0;
+
+	if ((error = config_is_modified(&modified, &b->file)) < 0 && error != GIT_ENOTFOUND)
 		goto out;
 
 	if (!modified)