Browse Source

proxy: bounds check data_len перед memcpy в handle_data — fix buffer overflow

bbr
Evgeny 4 months ago
parent
commit
7c456a1652
  1. 5
      src/proxy/tcp_proxy_server.c

5
src/proxy/tcp_proxy_server.c

@ -326,6 +326,11 @@ int tcp_proxy_server_handle_data(struct UTUN_INSTANCE* inst, struct ETCP_CONN* c
} }
size_t data_len = entry->len - TCP_PROXY_HDR_SIZE; size_t data_len = entry->len - TCP_PROXY_HDR_SIZE;
if (data_len > 0) { if (data_len > 0) {
if (data_len > rc->tc->data_pool->object_size) {
DEBUG_ERROR(DEBUG_CATEGORY_SOCKET, "tcp_proxy_server: data_len=%zu > pool_sz=%zu, dropping sid=%08x",
data_len, rc->tc->data_pool->object_size, stream_id);
queue_dgram_free(entry); queue_entry_free(entry); return -1;
}
struct ll_entry* e = queue_entry_new_from_pool(rc->tc->entry_pool); struct ll_entry* e = queue_entry_new_from_pool(rc->tc->entry_pool);
uint8_t* buf = memory_pool_alloc(rc->tc->data_pool); uint8_t* buf = memory_pool_alloc(rc->tc->data_pool);
if (e && buf) { if (e && buf) {

Loading…
Cancel
Save