summaryrefslogtreecommitdiff
path: root/tests-clar/diff/diff_helpers.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-07-05 16:59:38 -0700
committerRussell Belfer <rb@github.com>2013-07-05 16:59:38 -0700
commita5f9b5f8d8c2dbcd1bec92065e5df7bae76d3c7c (patch)
treeba8962145082f91aa6a7473869457e741ba38c95 /tests-clar/diff/diff_helpers.c
parent82cb8e236a07d8684c53aa8ee5b1c6195f788371 (diff)
downloadlibgit2-a5f9b5f8d8c2dbcd1bec92065e5df7bae76d3c7c.tar.gz
Diff hunk context off by one on long lines
The diff hunk context string that is returned to xdiff need not be NUL terminated because the xdiff code just copies the number of bytes that you report directly into the output. There was an off by one in the diff driver code when the header context was longer than the output buffer size, the output buffer length included the NUL byte which was copied into the hunk header. Fixes #1710
Diffstat (limited to 'tests-clar/diff/diff_helpers.c')
-rw-r--r--tests-clar/diff/diff_helpers.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests-clar/diff/diff_helpers.c b/tests-clar/diff/diff_helpers.c
index 4e23792a6..a5c322b4d 100644
--- a/tests-clar/diff/diff_helpers.c
+++ b/tests-clar/diff/diff_helpers.c
@@ -70,8 +70,9 @@ int diff_hunk_cb(
diff_expects *e = payload;
GIT_UNUSED(delta);
- GIT_UNUSED(header);
- GIT_UNUSED(header_len);
+
+ /* confirm no NUL bytes in header text */
+ while (header_len--) cl_assert('\0' != *header++);
e->hunks++;
e->hunk_old_lines += range->old_lines;