News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

network: validate HTTP Content-Length on the client

Started by janry, Yesterday at 12:41:54 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

janry

Sanitize content-length received from server. Trusting what comes on the wire produces nasty failure modes.

The HTTP client used for the announce-server list, the external-IP query, and the pakset downloader trusted the wire Content-Length:
parse via atol() into sint32, then `new char[length + 1]` plus `network_receive_data(..., length, ...)`.
Negative values gave a zero-byte allocation paired with a uint16-truncated read length of 0xFFFF -> OOB write.
INT32_MAX overflowed the signed `length+1` to a huge size_t and tripped uncaught bad_alloc.

Cheers, Jan