summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordelanne <xavier.delannoy@gmail.com>2012-11-08 12:28:21 +0100
committerdelanne <xavier.delannoy@gmail.com>2012-11-08 12:28:21 +0100
commitbcad677ba8e0c0c220b758e2203f5bfe3506bc81 (patch)
tree91a4b5820a13451e5cdfa89c96d368aecceeb3de
parent8ff2b0c75983160264ee7c45a01bde27cfbc91ea (diff)
downloadlibgit2-bcad677ba8e0c0c220b758e2203f5bfe3506bc81.tar.gz
- Update 'tests-clar/resources/config/config11' in order to reproduce the invalidread with the unittest (just added some \n at the end of the file)
- Fix config_file.c
-rw-r--r--src/config_file.c4
-rw-r--r--tests-clar/resources/config/config112
2 files changed, 4 insertions, 2 deletions
diff --git a/src/config_file.c b/src/config_file.c
index 1eae8b9ac..4ca842b89 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -924,7 +924,7 @@ static int strip_comments(char *line, int in_quotes)
}
/* skip any space at the end */
- if (git__isspace(ptr[-1])) {
+ if (ptr > line && git__isspace(ptr[-1])) {
ptr--;
}
ptr[0] = '\0';
@@ -1398,7 +1398,7 @@ static int parse_variable(diskfile_backend *cfg, char **var_name, char **var_val
value_start = var_end + 1;
do var_end--;
- while (git__isspace(*var_end));
+ while (var_end>line && git__isspace(*var_end));
*var_name = git__strndup(line, var_end - line + 1);
GITERR_CHECK_ALLOC(*var_name);
diff --git a/tests-clar/resources/config/config11 b/tests-clar/resources/config/config11
index 880c94589..7331862a5 100644
--- a/tests-clar/resources/config/config11
+++ b/tests-clar/resources/config/config11
@@ -1,3 +1,5 @@
[remote "fancy"]
url = git://github.com/libgit2/libgit2
url = git://git.example.com/libgit2
+
+