tests: Fix buffer overrun

This commit is contained in:
Tatsuhiro Tsujikawa 2013-09-08 15:29:46 +09:00
parent 1a05caf847
commit a67d042a00
2 changed files with 4 additions and 4 deletions

View File

@ -138,7 +138,7 @@ void test_nghttp2_frame_pack_headers_frame_too_large(void)
ssize_t nvlen; ssize_t nvlen;
size_t big_vallen = NGHTTP2_MAX_HD_VALUE_LENGTH; size_t big_vallen = NGHTTP2_MAX_HD_VALUE_LENGTH;
char *big_hds[17]; char *big_hds[17];
size_t big_hdslen = sizeof(big_hds)/sizeof(big_hds[0]); size_t big_hdslen = sizeof(big_hds)/sizeof(big_hds[0]) - 1;
size_t i; size_t i;
for(i = 0; i < big_hdslen; i += 2) { for(i = 0; i < big_hdslen; i += 2) {
@ -147,7 +147,7 @@ void test_nghttp2_frame_pack_headers_frame_too_large(void)
memset(big_hds[i+1], '0'+i, big_vallen); memset(big_hds[i+1], '0'+i, big_vallen);
big_hds[i+1][big_vallen] = '\0'; big_hds[i+1][big_vallen] = '\0';
} }
big_hds[big_hdslen - 1] = NULL; big_hds[big_hdslen] = NULL;
nvlen = nghttp2_nv_array_from_cstr(&nva, (const char**)big_hds); nvlen = nghttp2_nv_array_from_cstr(&nva, (const char**)big_hds);
nghttp2_hd_deflate_init(&deflater, NGHTTP2_HD_SIDE_CLIENT); nghttp2_hd_deflate_init(&deflater, NGHTTP2_HD_SIDE_CLIENT);

View File

@ -1376,7 +1376,7 @@ void test_nghttp2_session_send_headers_header_comp_error(void)
ssize_t nvlen; ssize_t nvlen;
size_t vallen = NGHTTP2_MAX_HD_VALUE_LENGTH; size_t vallen = NGHTTP2_MAX_HD_VALUE_LENGTH;
char *nv[17]; char *nv[17];
size_t nnv = sizeof(nv)/sizeof(nv[0]); size_t nnv = sizeof(nv)/sizeof(nv[0]) - 1;
size_t i; size_t i;
for(i = 0; i < nnv; i += 2) { for(i = 0; i < nnv; i += 2) {
@ -1385,7 +1385,7 @@ void test_nghttp2_session_send_headers_header_comp_error(void)
memset(nv[i+1], '0'+i, vallen); memset(nv[i+1], '0'+i, vallen);
nv[i+1][vallen] = '\0'; nv[i+1][vallen] = '\0';
} }
nv[nnv - 1] = NULL; nv[nnv] = NULL;
memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); memset(&callbacks, 0, sizeof(nghttp2_session_callbacks));
callbacks.send_callback = null_send_callback; callbacks.send_callback = null_send_callback;