From 23593c93d4ed705119e7688d1e4b114e7d63e00f Mon Sep 17 00:00:00 2001 From: Stjepan Rajko Date: Mon, 19 Oct 2015 16:55:12 -0700 Subject: [PATCH] Update libgit2 to include segfault fix for git_reflog_read --- .gitmodules | 2 +- package.json | 2 +- vendor/libgit2/docs/error-handling.md | 2 +- vendor/libgit2/src/refdb_fs.c | 2 +- vendor/libgit2/tests/refs/reflog/reflog.c | 16 ++++++++++++++++ .../testrepo.git/logs/refs/heads/extra-newline | 3 +++ 6 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 vendor/libgit2/tests/resources/testrepo.git/logs/refs/heads/extra-newline diff --git a/.gitmodules b/.gitmodules index ca6a48f0b..ed21ded67 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "vendor/libgit2"] path = vendor/libgit2 - url = git://github.com/libgit2/libgit2.git + url = git://github.com/nodegit/libgit2.git diff --git a/package.json b/package.json index 678970086..ece37c894 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ }, "vendorDependencies": { "libgit2": { - "sha": "fe965028885fbd8c62dce08e3a86cd3cb3e3b320", + "sha": "dbf0c5c86ea2c0c621ba9ef5cbd5bb326d266989", "version": "0.23.3" }, "libssh2": "1.6.0", diff --git a/vendor/libgit2/docs/error-handling.md b/vendor/libgit2/docs/error-handling.md index 2dbe64a71..719244d2f 100644 --- a/vendor/libgit2/docs/error-handling.md +++ b/vendor/libgit2/docs/error-handling.md @@ -128,7 +128,7 @@ The public error API bugs, but in the meantime, please code defensively and check for NULL when calling this function. -- `void geterr_clear(void)`: This function clears the last error. The +- `void giterr_clear(void)`: This function clears the last error. The library will call this when an error is generated by low level function and the higher level function handles the error. diff --git a/vendor/libgit2/src/refdb_fs.c b/vendor/libgit2/src/refdb_fs.c index e1a77f3ff..792e4bb0a 100644 --- a/vendor/libgit2/src/refdb_fs.c +++ b/vendor/libgit2/src/refdb_fs.c @@ -1453,7 +1453,7 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size) entry = git__calloc(1, sizeof(git_reflog_entry)); GITERR_CHECK_ALLOC(entry); - entry->committer = git__malloc(sizeof(git_signature)); + entry->committer = git__calloc(1, sizeof(git_signature)); GITERR_CHECK_ALLOC(entry->committer); if (git_oid_fromstrn(&entry->oid_old, buf, GIT_OID_HEXSZ) < 0) diff --git a/vendor/libgit2/tests/refs/reflog/reflog.c b/vendor/libgit2/tests/refs/reflog/reflog.c index 56ec422c3..d2b8e0fa3 100644 --- a/vendor/libgit2/tests/refs/reflog/reflog.c +++ b/vendor/libgit2/tests/refs/reflog/reflog.c @@ -154,6 +154,22 @@ void test_refs_reflog_reflog__reading_the_reflog_from_a_reference_with_no_log_re git_buf_free(&subtrees_log_path); } +void test_refs_reflog_reflog__reading_a_reflog_with_invalid_format_returns_error(void) +{ + git_reflog *reflog; + const git_error *error; + + /* clear the error state so we can capture the error generated by git_reflog_read */ + giterr_clear(); + + cl_git_fail(git_reflog_read(&reflog, g_repo, "refs/heads/extra-newline")); + + error = giterr_last(); + + cl_assert(error != NULL); + cl_assert_equal_s("Unable to parse OID - contains invalid characters", error->message); +} + void test_refs_reflog_reflog__cannot_write_a_moved_reflog(void) { git_reference *master, *new_master; diff --git a/vendor/libgit2/tests/resources/testrepo.git/logs/refs/heads/extra-newline b/vendor/libgit2/tests/resources/testrepo.git/logs/refs/heads/extra-newline new file mode 100644 index 000000000..c809e0137 --- /dev/null +++ b/vendor/libgit2/tests/resources/testrepo.git/logs/refs/heads/extra-newline @@ -0,0 +1,3 @@ +0000000000000000000000000000000000000000 be3563ae3f795b2b4353bcce3a527ad0a4f7f644 Ben Straub 1335806563 -0800 clone: from +/Users/ben/src/libgit2/tests/resources/testrepo.git +be3563ae3f795b2b4353bcce3a527ad0a4f7f644 a65fedf39aefe402d3bb6e24df4d4f5fe4547750 Ben Straub 1335806603 -0800 commit: checking in