From a5f9b5f8d8c2dbcd1bec92065e5df7bae76d3c7c Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Fri, 5 Jul 2013 16:59:38 -0700 Subject: 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 --- tests-clar/diff/diff_helpers.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests-clar/diff/diff_helpers.c') 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; -- cgit v1.2.1