Validate the complete UDP INIT request body before reading fields
This commit is contained in:
1 parent
10927b1d08
commit
0860b1e06d
2 files changed
+4
-3
No files matched your search
@@ -2403,8 +2403,9 @@ static void etcp_process_packet(struct ETCP_SOCKET* e_sock, uint8_t* data,
|
||||
errorcode=8;
|
||||
goto ec_fr;
|
||||
}
|
||||
if (pkt_len < ETCP_INIT_REQ_SIZE) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "INIT REQUEST too short: pkt_len=%zu from %s", pkt_len, sockaddr_storage_to_str(&addr).str);
|
||||
if (pkt->data_len < ETCP_INIT_REQ_SIZE) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "INIT REQUEST too short: code=%02x body=%u required=%zu from=%s",
|
||||
code, pkt->data_len, (size_t)ETCP_INIT_REQ_SIZE, sockaddr_storage_to_str(&addr).str);
|
||||
errorcode=7;
|
||||
goto ec_fr;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ static inline unsigned etcp_ack_section_size(uint8_t count) {
|
||||
// INIT внутри шифрованного тела, до padding: запрос — 67 байт, ответ — 64 байта.
|
||||
// Каждая сторона передаёт свою эпоху reset_id; смена известной эпохи подтверждается через etcp_session.
|
||||
|
||||
// INIT REQUEST: client → server
|
||||
// INIT REQUEST: client → server. Проверить всё 67-байтовое тело до чтения полей и изменения транспорта; padding допустим.
|
||||
struct ETCP_INIT_REQUEST_PKT {
|
||||
uint8_t code; // 0: ETCP_INIT_REQUEST (0x02) или ETCP_INIT_REQUEST_NOINIT (0x04)
|
||||
uint8_t node_id[8]; // 1: sender node_id (big-endian)
|
||||
|
||||
Reference in new issue
Block a user