Add test for GH-232

This commit is contained in:
Tatsuhiro Tsujikawa 2015-05-15 01:00:09 +09:00
parent 24fe24b37d
commit 252aeb43e1
3 changed files with 23 additions and 0 deletions

View File

@ -340,6 +340,8 @@ int main(int argc _U_, char *argv[] _U_) {
!CU_add_test(pSuite, "check_header_value", !CU_add_test(pSuite, "check_header_value",
test_nghttp2_check_header_value) || test_nghttp2_check_header_value) ||
!CU_add_test(pSuite, "bufs_add", test_nghttp2_bufs_add) || !CU_add_test(pSuite, "bufs_add", test_nghttp2_bufs_add) ||
!CU_add_test(pSuite, "bufs_add_stack_buffer_overflow_bug",
test_nghttp2_bufs_add_stack_buffer_overflow_bug) ||
!CU_add_test(pSuite, "bufs_addb", test_nghttp2_bufs_addb) || !CU_add_test(pSuite, "bufs_addb", test_nghttp2_bufs_addb) ||
!CU_add_test(pSuite, "bufs_orb", test_nghttp2_bufs_orb) || !CU_add_test(pSuite, "bufs_orb", test_nghttp2_bufs_orb) ||
!CU_add_test(pSuite, "bufs_remove", test_nghttp2_bufs_remove) || !CU_add_test(pSuite, "bufs_remove", test_nghttp2_bufs_remove) ||

View File

@ -63,6 +63,26 @@ void test_nghttp2_bufs_add(void) {
nghttp2_bufs_free(&bufs); nghttp2_bufs_free(&bufs);
} }
/* Test for GH-232, stack-buffer-overflow */
void test_nghttp2_bufs_add_stack_buffer_overflow_bug(void) {
int rv;
nghttp2_bufs bufs;
uint8_t data[1024];
nghttp2_mem *mem;
mem = nghttp2_mem_default();
rv = nghttp2_bufs_init(&bufs, 100, 200, mem);
CU_ASSERT(0 == rv);
rv = nghttp2_bufs_add(&bufs, data, sizeof(data));
CU_ASSERT(0 == rv);
CU_ASSERT(sizeof(data) == nghttp2_bufs_len(&bufs));
nghttp2_bufs_free(&bufs);
}
void test_nghttp2_bufs_addb(void) { void test_nghttp2_bufs_addb(void) {
int rv; int rv;
nghttp2_bufs bufs; nghttp2_bufs bufs;

View File

@ -26,6 +26,7 @@
#define NGHTTP2_BUF_TEST_H #define NGHTTP2_BUF_TEST_H
void test_nghttp2_bufs_add(void); void test_nghttp2_bufs_add(void);
void test_nghttp2_bufs_add_stack_buffer_overflow_bug(void);
void test_nghttp2_bufs_addb(void); void test_nghttp2_bufs_addb(void);
void test_nghttp2_bufs_orb(void); void test_nghttp2_bufs_orb(void);
void test_nghttp2_bufs_remove(void); void test_nghttp2_bufs_remove(void);