summaryrefslogtreecommitdiff
path: root/tests/core
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2013-12-13 12:41:22 +0100
committerVicent Marti <tanoku@gmail.com>2013-12-13 12:41:22 +0100
commit437f7d69b22324d20fe833aa53119885733029c2 (patch)
tree37721b5fecf60604a157085a3a1c979531b0bda8 /tests/core
parentce33645ff32d68dfd89867468f58fd9c245c26ff (diff)
downloadlibgit2-437f7d69b22324d20fe833aa53119885733029c2.tar.gz
pool: Correct overflow checks
Ok, scrap the previous commit. This is the right overflow check that takes care of 64 bit overflow **and** 32-bit overflow, which needs to be considered because the pool malloc can only allocate 32-bit elements in one go.
Diffstat (limited to 'tests/core')
-rw-r--r--tests/core/pool.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/core/pool.c b/tests/core/pool.c
index 3073c4a45..7a8b2dea6 100644
--- a/tests/core/pool.c
+++ b/tests/core/pool.c
@@ -139,7 +139,11 @@ void test_core_pool__strndup_limit(void)
git_pool p;
cl_git_pass(git_pool_init(&p, 1, 100));
- cl_assert(git_pool_strndup(&p, "foo", -1) == NULL);
+ /* ensure 64 bit doesn't overflow */
+ cl_assert(git_pool_strndup(&p, "foo", (size_t)-1) == NULL);
+
+ /* ensure 32 bit doesn't overflow */
+ cl_assert(git_pool_strndup(&p, "bar", 0xfffffffful + 32) == NULL);
git_pool_clear(&p);
}