/* Copyright (c) 2016-2018 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
static void test_malloc_overflow_multiply(void)
{
static const struct {
size_t a, b;
} tests[] = {
{ 0, SIZE_MAX },
{ 1, SIZE_MAX },
};
test_begin("MALLOC_MULTIPLY()");
for (unsigned int i = 0; i < N_ELEMENTS(tests); i++) {
}
test_end();
}
static void test_malloc_overflow_add(void)
{
static const struct {
size_t a, b;
} tests[] = {
{ 0, SIZE_MAX },
};
unsigned short n = 2;
test_begin("MALLOC_ADD()");
/* check that no compiler warning is given */
for (unsigned int i = 0; i < N_ELEMENTS(tests); i++) {
}
test_end();
}
void test_malloc_overflow(void)
{
}
{
const struct {
size_t a, b;
} mul_tests[] = {
};
unsigned int i;
test_expect_fatal_string("memory allocation overflow");
switch (*stage) {
case 0:
test_begin("MALLOC_MULTIPLY() overflows");
break;
case 1:
break;
}
*stage -= 2;
if (*stage == 0)
test_end();
return FATAL_TEST_FINISHED;
}
i = *stage / 2;
if (*stage % 2 == 0)
else
return FATAL_TEST_FAILURE;
}
{
const struct {
size_t a, b;
} add_tests[] = {
{ SIZE_MAX, 1 },
};
unsigned int i;
test_expect_fatal_string("memory allocation overflow");
switch (*stage) {
case 0:
test_begin("MALLOC_ADD() overflows");
break;
case 1:
break;
}
*stage -= 2;
if (*stage == 0)
test_end();
return FATAL_TEST_FINISHED;
}
i = *stage / 2;
if (*stage % 2 == 0)
else
return FATAL_TEST_FAILURE;
}
{
if (state != FATAL_TEST_FINISHED)
return state;
return fatal_malloc_overflow_add(&stage);
}