Files
utun2/tests/buffer_overflow_fix.patch
T
Evgeny d74f76a5a0 Fix: Resolved double free in timeout_heap_pop() and test_etcp_simple_traffic bind conflict
- Fixed incorrect init_connections() call in test_etcp_simple_traffic.c (was calling server_instance instead of client_instance)
- Fixed double free in timeout_heap_pop() when handling deleted elements
- Enhanced NULL pointer safety in uasync_print_resources() by removing complex heap manipulation
- Added debug logging to timeout_heap_pop() for better error tracking

Test results: test_etcp_simple_traffic now passes without double free errors
2026-01-25 10:47:02 +03:00

39 lines
1.5 KiB
Diff

--- test_etcp_simple_traffic.c.backup
+++ test_etcp_simple_traffic.c
@@ -172,19 +172,25 @@
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "SIMULATE RX: inst=%s, len=%u",
inst->is_server ? "server" : "client", len);
- // Create a mock ETCP_DGRAM for processing
- struct ETCP_DGRAM mock_dgram;
- memset(&mock_dgram, 0, sizeof(mock_dgram));
- mock_dgram.link = NULL; // Will be set by connection processing
- mock_dgram.data_len = len > 1500 ? 1500 : len;
- mock_dgram.timestamp = get_current_timestamp();
- if (mock_dgram.data_len > 0) {
- memcpy(mock_dgram.data, data, mock_dgram.data_len);
+ // Create a mock ETCP_DGRAM for processing with proper allocation
+ size_t dgram_size = sizeof(struct ETCP_DGRAM) + (len > 1500 ? 1500 : len);
+ struct ETCP_DGRAM* mock_dgram = malloc(dgram_size);
+ if (!mock_dgram) {
+ DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "Failed to allocate mock dgram");
+ return;
+ }
+ memset(mock_dgram, 0, dgram_size);
+ mock_dgram->link = NULL; // Will be set by connection processing
+ mock_dgram->data_len = len > 1500 ? 1500 : len;
+ mock_dgram->timestamp = get_current_timestamp();
+ if (mock_dgram->data_len > 0) {
+ memcpy(mock_dgram->data, data, mock_dgram->data_len);
}
// Process through ETCP input
- etcp_conn_input(&mock_dgram);
+ etcp_conn_input(mock_dgram);
+
+ // Free the allocated memory
+ free(mock_dgram);
}
// Simulate packet transmission for analysis