[PATCH 2/3] t1007: add hash-object --literally tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



git-hash-object learned a --literally option in 5ba9a93 (hash-object:
add --literally option, 2014-09-11). Check that --literally allows
object creation with a bogus type.

Also add a failing test demonstrating a crash (buffer overflow leading
to stack corruption) when the bogus type is lengthy.

Signed-off-by: Eric Sunshine <sunshine@xxxxxxxxxxxxxx>
---

Although the crash seems to have manifested[1] only on Mac OS X when
testing Karthik's "cat-file --allow-unknown-type" series, I made the
bogus object type extremely long in the failing test included here in
order to ensure that it manifests (hopefully) everywhere. At this
length, the crash manifest on Linux as well.

[1]: http://thread.gmane.org/gmane.comp.version-control.git/268262/focus=268304

 t/t1007-hash-object.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh
index f83df8e..0e65577 100755
--- a/t/t1007-hash-object.sh
+++ b/t/t1007-hash-object.sh
@@ -201,4 +201,15 @@ test_expect_success 'corrupt tag' '
 	test_must_fail git hash-object -t tag --stdin </dev/null
 '
 
+test_expect_success '--literally' '
+	t=1234567890 &&
+	echo example | git hash-object -t $t --literally --stdin
+'
+
+test_expect_failure '--literally with extra-long type' '
+	t=12345678901234567890123456789012345678901234567890 &&
+	t="$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t$t" &&
+	echo example | git hash-object -t $t --literally --stdin
+'
+
 test_done
-- 
2.4.0.319.g7a04823

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]