diff options
| author | Patrick Steinhardt <ps@pks.im> | 2019-10-21 18:56:59 +0200 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2019-10-21 20:07:42 +0200 |
| commit | 37141ff7701e45ab0d97f311a4e0cc95cf527aa9 (patch) | |
| tree | 1f9353c309550c7d3128570f007fdfa8e3de5d71 /tests/patch/patch_common.h | |
| parent | 468e3ddc344d6374a615fb2199005956ad0eb531 (diff) | |
| download | libgit2-37141ff7701e45ab0d97f311a4e0cc95cf527aa9.tar.gz | |
patch_parse: detect overflow when calculating old/new line position
When the patch contains lines close to INT_MAX, then it may happen that
we end up with an integer overflow when calculating the line of the
current diff hunk. Reject such patches as unreasonable to avoid the
integer overflow.
As the calculation is performed on integers, we introduce two new
helpers `git__add_int_overflow` and `git__sub_int_overflow` that perform
the integer overflow check in a generic way.
Diffstat (limited to 'tests/patch/patch_common.h')
| -rw-r--r-- | tests/patch/patch_common.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/patch/patch_common.h b/tests/patch/patch_common.h index 4c053cbbf..153bab57f 100644 --- a/tests/patch/patch_common.h +++ b/tests/patch/patch_common.h @@ -918,3 +918,11 @@ "+++ \n" \ "index 0000..7DDb\n" \ "--- \n" + +#define PATCH_INTMAX_NEW_LINES \ + "diff --git a/file b/file\n" \ + "--- a/file\n" \ + "+++ b/file\n" \ + "@@ -0 +2147483647 @@\n" \ + "\n" \ + " " |
