From be7cc9710f42ec4ee4ae9c5dae7d0b44ef7ce697 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 4 Feb 2012 23:27:05 +0900 Subject: [PATCH] Added asserts to test_spdylay_frame_count_unpack_nv_space() --- tests/spdylay_frame_test.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/spdylay_frame_test.c b/tests/spdylay_frame_test.c index f4f918c5..897ce609 100644 --- a/tests/spdylay_frame_test.c +++ b/tests/spdylay_frame_test.c @@ -27,6 +27,7 @@ #include #include "spdylay_frame.h" +#include "spdylay_helper.h" static const char *headers[] = { "method", "GET", @@ -69,10 +70,26 @@ void test_spdylay_frame_count_unpack_nv_space() size_t nvlen, buflen; uint8_t out[1024]; size_t inlen = spdylay_frame_pack_nv(out, (char**)headers); + uint16_t temp; CU_ASSERT(0 == spdylay_frame_count_unpack_nv_space(&nvlen, &buflen, out, inlen)); CU_ASSERT(6 == nvlen); CU_ASSERT(166 == buflen); + /* Change number of nv pair to a bogus value */ + temp = spdylay_get_uint16(out); + spdylay_put_uint16be(out, temp+1); + CU_ASSERT(SPDYLAY_ERR_INVALID_ARGUMENT == + spdylay_frame_count_unpack_nv_space(&nvlen, &buflen, out, inlen)); + spdylay_put_uint16be(out, temp); + + /* Change the length of name to a bogus value */ + temp = spdylay_get_uint16(out+2); + spdylay_put_uint16be(out+2, temp+1); + CU_ASSERT(SPDYLAY_ERR_INVALID_ARGUMENT == + spdylay_frame_count_unpack_nv_space(&nvlen, &buflen, out, inlen)); + spdylay_put_uint16be(out+2, 65536); + CU_ASSERT(SPDYLAY_ERR_INVALID_ARGUMENT == + spdylay_frame_count_unpack_nv_space(&nvlen, &buflen, out, inlen)); } void test_spdylay_frame_pack_ping()