Commit 252aeb43 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Add test for GH-232

parent 24fe24b3
...@@ -340,6 +340,8 @@ int main(int argc _U_, char *argv[] _U_) { ...@@ -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) ||
......
...@@ -63,6 +63,26 @@ void test_nghttp2_bufs_add(void) { ...@@ -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;
......
...@@ -26,6 +26,7 @@ ...@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment