summaryrefslogtreecommitdiff
path: root/src/config_parse.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-02-08 10:27:31 +0000
committerPatrick Steinhardt <ps@pks.im>2018-02-08 17:13:54 +0000
commit2eea5f1cb8a75be997636ebc57c8166f05b324d7 (patch)
tree448366ffddd1bda74d17b92ef0012eff2b6402e6 /src/config_parse.c
parent848153f386b45363d033c72e155e4001d0217f96 (diff)
downloadlibgit2-2eea5f1cb8a75be997636ebc57c8166f05b324d7.tar.gz
config_parse: fix reading files with BOM
The function `skip_bom` is being used to detect and skip BOM marks previously to parsing a configuration file. To do so, it simply uses `git_buf_text_detect_bom`. But since the refactoring to use the parser interface in commit 9e66590bd (config_parse: use common parser interface, 2017-07-21), the BOM detection was actually broken. The issue stems from a misunderstanding of `git_buf_text_detect_bom`. It was assumed that its third parameter limits the length of the character sequence that is to be analyzed, while in fact it was an offset at which we want to detect the BOM. Fix the parameter to be `0` instead of the buffer length, as we always want to check the beginning of the configuration file.
Diffstat (limited to 'src/config_parse.c')
-rw-r--r--src/config_parse.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/config_parse.c b/src/config_parse.c
index 981f968bb..49c948c79 100644
--- a/src/config_parse.c
+++ b/src/config_parse.c
@@ -217,7 +217,7 @@ static int skip_bom(git_parse_ctx *parser)
{
git_buf buf = GIT_BUF_INIT_CONST(parser->content, parser->content_len);
git_bom_t bom;
- int bom_offset = git_buf_text_detect_bom(&bom, &buf, parser->content_len);
+ int bom_offset = git_buf_text_detect_bom(&bom, &buf, 0);
if (bom == GIT_BOM_UTF8)
git_parse_advance_chars(parser, bom_offset);