diff options
| author | Patrick Steinhardt <ps@pks.im> | 2018-11-13 14:26:26 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-13 14:26:26 +0100 |
| commit | cf83809b9d4b142ec1250b19a902b3eb7744e014 (patch) | |
| tree | 3ec8764e475a8ca0ac4a30463677468c7a743fb9 /tests | |
| parent | 20cb30b6b8e269d2ce3474523562b2739a8efea2 (diff) | |
| parent | 52f859fd534e3c16c2c03b9a2375f00a50f3996e (diff) | |
| download | libgit2-cf83809b9d4b142ec1250b19a902b3eb7744e014.tar.gz | |
Merge pull request #4883 from pks-t/pks/signature-tz-oob
signature: fix out-of-bounds read when parsing timezone offset
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/commit/signature.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/commit/signature.c b/tests/commit/signature.c index 78ddbbef3..a91551415 100644 --- a/tests/commit/signature.c +++ b/tests/commit/signature.c @@ -43,6 +43,26 @@ void test_commit_signature__leading_and_trailing_crud_is_trimmed(void) assert_name_and_email("nulltoken \xe2\x98\xba", "emeric.fermas@gmail.com", "nulltoken \xe2\x98\xba", "emeric.fermas@gmail.com"); } +void test_commit_signature__timezone_does_not_read_oob(void) +{ + const char *header = "A <a@example.com> 1461698487 +1234", *header_end; + git_signature *sig; + + /* Let the buffer end midway between the timezone offeset's "+12" and "34" */ + header_end = header + strlen(header) - 2; + + sig = git__calloc(1, sizeof(git_signature)); + cl_assert(sig); + + cl_git_pass(git_signature__parse(sig, &header, header_end, NULL, '\0')); + cl_assert_equal_s(sig->name, "A"); + cl_assert_equal_s(sig->email, "a@example.com"); + cl_assert_equal_i(sig->when.time, 1461698487); + cl_assert_equal_i(sig->when.offset, 12); + + git_signature_free(sig); +} + void test_commit_signature__angle_brackets_in_names_are_not_supported(void) { cl_git_fail(try_build_signature("<Phil Haack", "phil@haack", 1234567890, 60)); |
