Signed-off-by: Johannes Schindelin <[email protected]>
---
Makefile | 1 +
t/helper/test-sha1.c | 10 ++++++++++
t/t0013-sha1dc.sh | 10 ++++++++++
3 files changed, 21 insertions(+)
diff --git a/Makefile b/Makefile
index 3e181d2f0e2..0b581357625 100644
--- a/Makefile
+++ b/Makefile
@@ -2251,6 +2251,7 @@ GIT-BUILD-OPTIONS: FORCE
@echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst
','\'',$(NO_UNIX_SOCKETS)))'\' >>$@+
@echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+
@echo DC_SHA1=\''$(subst ','\'',$(subst ','\'',$(DC_SHA1)))'\' >>$@+
+ @echo DC_AND_OPENSSL_SHA1=\''$(subst ','\'',$(subst
','\'',$(DC_AND_OPENSSL_SHA1)))'\' >>$@+
ifdef TEST_OUTPUT_DIRECTORY
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst
','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
endif
diff --git a/t/helper/test-sha1.c b/t/helper/test-sha1.c
index a1c13f54eca..27ce8869e51 100644
--- a/t/helper/test-sha1.c
+++ b/t/helper/test-sha1.c
@@ -8,6 +8,16 @@ int cmd_main(int ac, const char **av)
int binary = 0;
char *buffer;
+ if (ac > 1 && !strcmp(av[1], "--disable-sha1dc")) {
+#ifdef SHA1_DC_AND_OPENSSL
+ toggle_sha1dc(0);
+#else
+ die("Not compiled with DC_AND_OPENSSL_SHA1");
+#endif
+ ac--;
+ av++;
+ }
+
if (ac == 2) {
if (!strcmp(av[1], "-b"))
binary = 1;
diff --git a/t/t0013-sha1dc.sh b/t/t0013-sha1dc.sh
index 435a96d6108..2b529b31b4e 100755
--- a/t/t0013-sha1dc.sh
+++ b/t/t0013-sha1dc.sh
@@ -5,6 +5,10 @@ test_description='test sha1 collision detection'
TEST_DATA="$TEST_DIRECTORY/t0013"
test -z "$DC_SHA1" || test_set_prereq DC_SHA1
+test -z "$DC_AND_OPENSSL_SHA1" || {
+ test_set_prereq DC_AND_OPENSSL_SHA1
+ test_set_prereq DC_SHA1
+}
test_expect_success DC_SHA1 'test-sha1 detects shattered pdf' '
test_must_fail test-sha1 <"$TEST_DATA/shattered-1.pdf" 2>err &&
@@ -12,4 +16,10 @@ test_expect_success DC_SHA1 'test-sha1 detects shattered
pdf' '
grep 38762cf7f55934b34d179ae6a4c80cadccbb7f0a err
'
+test_expect_success DC_AND_OPENSSL_SHA1 'sha1dc can be turned off' '
+ test-sha1 --disable-sha1dc <"$TEST_DATA/shattered-1.pdf" 2>err &&
+ ! test_i18ngrep collision err &&
+ ! grep 38762cf7f55934b34d179ae6a4c80cadccbb7f0a err
+'
+
test_done
--
2.12.1.windows.1