Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2012-11-30 02:07:50 +0400
committerBen Straub <bs@github.com>2012-12-01 01:12:14 +0400
commit691776213947e59a3928aab09e97a64b65e990ab (patch)
treebd35b8ff4af040b6350fe83f802d988c954525e9 /src/config.c
parentb81aa2f1deb98eb7f9e60ac96696e69a9a49d8f8 (diff)
Deploy git_config_backend version
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index 6347f7df7..913108abb 100644
--- a/src/config.c
+++ b/src/config.c
@@ -248,6 +248,18 @@ int git_config_open_level(
return 0;
}
+static bool config_backend_has_valid_version(git_config_backend *backend)
+{
+ if (!backend)
+ return true;
+
+ if (backend->version > 0 && backend->version <= GIT_CONFIG_BACKEND_VERSION)
+ return true;
+
+ giterr_set(GITERR_INVALID, "Invalid version %d for git_config_backend", backend->version);
+ return false;
+}
+
int git_config_add_backend(
git_config *cfg,
git_config_backend *file,
@@ -259,6 +271,9 @@ int git_config_add_backend(
assert(cfg && file);
+ if (!config_backend_has_valid_version(file))
+ return -1;
+
if ((result = file->open(file, level)) < 0)
return result;