Possible out of bound exception

hdr_buf has size of 4096. Makes sense to assert that
we do not exceed this size before copying there
This commit is contained in:
Mikhail Lappo 2017-03-22 21:20:29 +01:00 committed by goldsimon
parent d386374449
commit 89b6fa479e

View File

@ -989,10 +989,10 @@ int file_write_http_header(FILE *data_file, const char *filename, int file_size,
/* ATTENTION: headers are done now (double-CRLF has been written!) */
if (precalcChksum) {
LWIP_ASSERT("hdr_len + cur_len <= sizeof(hdr_buf)", hdr_len + cur_len <= sizeof(hdr_buf));
memcpy(&hdr_buf[hdr_len], cur_string, cur_len);
hdr_len += cur_len;
LWIP_ASSERT("hdr_len <= 0xffff", hdr_len <= 0xffff);
LWIP_ASSERT("strlen(hdr_buf) == hdr_len", strlen(hdr_buf) == hdr_len);
acc = ~inet_chksum(hdr_buf, (u16_t)hdr_len);
*http_hdr_len = (u16_t)hdr_len;