diff tests/test-import.t @ 37573:49b82cdb5983

patch: error out if reached to EOF while reading hunk This was where out-of-bounds read occurred in old C extension.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 09 Apr 2018 21:06:46 +0900
parents 9bf65d1b43a6
children 32a75a8a5b0f
line wrap: on
line diff
--- a/tests/test-import.t	Mon Apr 09 20:55:05 2018 +0900
+++ b/tests/test-import.t	Mon Apr 09 21:06:46 2018 +0900
@@ -1917,3 +1917,26 @@
   a not tracked!
   abort: source file 'a' does not exist
   [255]
+
+test immature end of hunk
+
+  $ hg import - <<'EOF'
+  > diff --git a/foo b/foo
+  > --- a/foo
+  > --- b/foo
+  > @@ -0,0 +1,1 @@
+  > EOF
+  applying patch from stdin
+  abort: bad hunk #1: incomplete hunk
+  [255]
+
+  $ hg import - <<'EOF'
+  > diff --git a/foo b/foo
+  > --- a/foo
+  > --- b/foo
+  > @@ -0,0 +1,1 @@
+  > \ No newline at end of file
+  > EOF
+  applying patch from stdin
+  abort: bad hunk #1: incomplete hunk
+  [255]