diff options
author | Russell Belfer <rb@github.com> | 2013-07-05 16:59:38 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-07-05 16:59:38 -0700 |
commit | a5f9b5f8d8c2dbcd1bec92065e5df7bae76d3c7c (patch) | |
tree | ba8962145082f91aa6a7473869457e741ba38c95 /tests-clar/diff/diff_helpers.c | |
parent | 82cb8e236a07d8684c53aa8ee5b1c6195f788371 (diff) | |
download | libgit2-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.c | 5 |
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; |