ulong store_addr = image_load_addr + offset;
uchar *ptr;
+ // Avoid overflow
+ if (wget_info->buffer_size && wget_info->buffer_size < offset + len)
+ return -1;
if (CONFIG_IS_ENABLED(LMB) && wget_info->set_bootdev) {
if (store_addr < image_load_addr ||
lmb_read_check(store_addr, len)) {
net_set_state(wget_loop_state);
if (wget_loop_state != NETLOOP_SUCCESS) {
net_boot_file_size = 0;
- if (wget_info->status_code == HTTP_STATUS_OK) {
- wget_info->status_code = HTTP_STATUS_BAD;
- wget_info->hdr_cont_len = 0;
- if (wget_info->headers)
- wget_info->headers[0] = 0;
- }
printf("\nwget: Transfer Fail, TCP status - %d\n", tcp->status);
return;
}
"wget: Connected Len %lu\n",
content_length);
wget_info->hdr_cont_len = content_length;
+ if (wget_info->buffer_size && wget_info->buffer_size < wget_info->hdr_cont_len){
+ tcp_stream_reset(tcp);
+ goto end;
+ }
+
}
net_boot_file_size = rx_bytes - http_hdr_size;
if ((max_rx_pos == (u32)(-1)) || (max_rx_pos < rx_offs + len - 1))
max_rx_pos = rx_offs + len - 1;
- store_block(buf, rx_offs - http_hdr_size, len);
+ // Avoid overflow
+ if (store_block(buf, rx_offs - http_hdr_size, len) < 0)
+ return -1;
return len;
}