Totally For Reals fix the segfaults

This commit is contained in:
Ximin Luo 2018-08-10 20:40:42 -07:00
parent 3a20e6037d
commit fe03ccf28c
4 changed files with 42 additions and 34 deletions

7
debian/changelog vendored
View File

@ -1,3 +1,10 @@
libgit2 (0.27.4+dfsg.1-0.1) UNRELEASED; urgency=medium
* Non-maintainer upload.
* Totally For Reals fix the segfaults. (Closes: #904004)
-- Ximin Luo <infinity0@debian.org> Fri, 10 Aug 2018 20:38:32 -0700
libgit2 (0.27.0+dfsg.1-0.9) unstable; urgency=medium
* Non-maintainer upload.

View File

@ -1,19 +0,0 @@
Description: Fix stack smashing error on 32-bit targets
Fix stack smashing due to wrong size of struct stat on the
stack on 32-bit systems with 64-bit file descriptor offsets
enabled by adding -D_FILE_OFFSET_BITS=64 when compiling the
test suite.
.
Author: Andreas Baumann <mail@andreasbaumann.cc>
Last-Update: 2018-05-26
--- libgit2-0.27.0+dfsg.1.orig/tests/CMakeLists.txt
+++ libgit2-0.27.0+dfsg.1/tests/CMakeLists.txt
@@ -9,6 +9,7 @@ SET(CLAR_FIXTURES "${CMAKE_CURRENT_SOURC
SET(CLAR_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
ADD_DEFINITIONS(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
ADD_DEFINITIONS(-DCLAR_TMPDIR=\"libgit2_tests\")
+ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64)
INCLUDE_DIRECTORIES(${CLAR_PATH} ${libgit2_BINARY_DIR}/src)
FILE(GLOB_RECURSE SRC_TEST ${CLAR_PATH}/*/*.c ${CLAR_PATH}/*/*.h)

View File

@ -2,5 +2,4 @@ use-mbedtls.patch
disable-online-tests.patch
remove-mbedtls-from-pkgconfig.patch
index-Fix-alignment-issues-in-write_disk_entry.patch
fix-stack-smashing-error.patch
u-segfault-fix.patch

View File

@ -1,17 +1,10 @@
commit d1919485a5541fb3171d6fa835c7c0de41243dea
Author: Edward Thomson <ethomson@edwardthomson.com>
Date: Sun Aug 5 11:01:14 2018 +0100
Bug: https://github.com/libgit2/libgit2/issues/4753
Bug: https://github.com/libgit2/libgit2/pull/4754
threads::diff: use separate git_repository objects
Our thread policies state that we cannot re-use the `git_repository`
across threads. Our tests cannot deviate from that.
diff --git a/tests/threads/diff.c b/tests/threads/diff.c
index 256040265..ab34b32a1 100644
--- a/tests/threads/diff.c
+++ b/tests/threads/diff.c
@@ -76,26 +76,29 @@ static void free_trees(void)
@@ -76,26 +76,29 @@
static void *run_index_diffs(void *arg)
{
int thread = *(int *)arg;
@ -46,7 +39,7 @@ index 256040265..ab34b32a1 100644
git_index_free(idx);
break;
}
@@ -132,6 +135,7 @@ static void *run_index_diffs(void *arg)
@@ -132,6 +135,7 @@
}
git_diff_free(diff);
@ -54,7 +47,7 @@ index 256040265..ab34b32a1 100644
giterr_clear();
return arg;
@@ -152,8 +156,10 @@ static void *run_index_diffs_with_modifier(void *arg)
@@ -152,8 +156,10 @@
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
git_diff *diff = NULL;
git_index *idx = NULL;
@ -66,7 +59,7 @@ index 256040265..ab34b32a1 100644
/* have first thread altering the index as we go */
if (thread == 0) {
@@ -176,17 +182,17 @@ static void *run_index_diffs_with_modifier(void *arg)
@@ -176,17 +182,17 @@
switch (thread & 0x03) {
case 0: /* diff index to workdir */;
@ -88,7 +81,7 @@ index 256040265..ab34b32a1 100644
break;
}
@@ -196,6 +202,7 @@ static void *run_index_diffs_with_modifier(void *arg)
@@ -196,6 +202,7 @@
done:
git_index_free(idx);
@ -96,3 +89,31 @@ index 256040265..ab34b32a1 100644
giterr_clear();
return arg;
--- a/tests/threads/iterator.c
+++ b/tests/threads/iterator.c
@@ -12,14 +12,16 @@
static void *run_workdir_iterator(void *arg)
{
int error = 0;
+ git_repository *repo;
git_iterator *iter;
git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
const git_index_entry *entry = NULL;
iter_opts.flags = GIT_ITERATOR_DONT_AUTOEXPAND;
+ cl_git_pass(git_repository_open(&repo, git_repository_path(_repo)));
cl_git_pass(git_iterator_for_workdir(
- &iter, _repo, NULL, NULL, &iter_opts));
+ &iter, repo, NULL, NULL, &iter_opts));
while (!error) {
if (entry && entry->mode == GIT_FILEMODE_TREE) {
@@ -38,6 +40,7 @@
cl_assert_equal_i(GIT_ITEROVER, error);
git_iterator_free(iter);
+ git_repository_free(repo);
giterr_clear();
return arg;
}