Commit Graph

23 Commits

Author SHA1 Message Date
whitequark 023d8deea5 Disable checksum validation on wire level when fuzzing. 2017-06-24 15:26:15 +00:00
whitequark fce23593fc Fix insufficient length validation in TCP packets.
Found via cargo-fuzz.
2017-06-24 12:29:39 +00:00
whitequark 9f8db1d8f9 Factor out wire::tcp::field::OPTIONS. 2017-06-24 12:02:34 +00:00
whitequark 315b51d7da Fix a crash parsing a truncated TCP packet with options.
Found via cargo-fuzz.
2017-06-24 11:48:17 +00:00
whitequark 6842d7013d Fix a crash parsing malformed TCP options.
Found via cargo-fuzz.
2017-06-24 11:48:17 +00:00
whitequark c09e96a657 Fix a crash printing a malformed TCP packet.
Found via cargo-fuzz.
2017-06-24 11:48:13 +00:00
whitequark 8b27330c8b Do not attempt to validate length of packets being emitted.
This is a form of an uninitialized read bug; although safe it caused
panics. In short, transmit buffers received from the network stack
should be considered uninitialized (in practice they will often
contain previously transmitted packets or parts thereof). Wrapping
them with the only method we had (e.g. Ipv4Packet) treated the buffer
as if it contained a valid incoming packet, which can easily fail
with Error::Truncated.

This commit splits every `fn new(buffer: T) -> Result<Self, Error>`
method on a `Packet` into three smaller ones:
  * `fn check_len(&self) -> Result<(), Error>`, purely a validator;
  * `fn new(T) -> Self`, purely a wrapper;
  * `fn new_checked(T) -> Result<Self, Error>`, a validating wrapper.

This makes it easy to process ingress packets (using `new_checked`),
egress packets (using `new`), and, if needed, maintain the invariants
at any point during packet construction (using `check_len`).

Fixes #17.
2017-06-24 11:42:32 +00:00
whitequark 077513fda6 Add support for TCP MSS option in TCP representation. 2017-01-27 02:56:27 +00:00
whitequark 4c3f454902 Add support for TCP option parsing and emission. 2017-01-27 00:33:30 +00:00
whitequark ca1146995f Remove TcpControl::len(). 2017-01-26 21:20:48 +00:00
whitequark 818e98f47a TCP: retransmit ACK when receiving duplicate SEQ. 2016-12-31 01:33:46 +00:00
whitequark be68066152 #[inline(always)] → #[inline] 2016-12-30 16:55:31 +00:00
whitequark 6b592742fd Use the correct wrapping operations on TCP sequence numbers. 2016-12-27 18:34:13 +00:00
whitequark 0ae27678a0 Implement TCP data reception. 2016-12-25 11:09:50 +00:00
whitequark 6d8d3cb29d Use correct sequence numbers in TCP RST packets. 2016-12-23 07:34:10 +00:00
whitequark 3bd715e1bc Use signed integers to represent TCP sequence numbers. 2016-12-23 07:34:07 +00:00
whitequark 5a64a87dbe Reply with ICMP dest. unreachable or TCP RST from unused ports. 2016-12-20 19:18:35 +00:00
whitequark 0d9a8a417d Add some sanity into enumeration names (avoid "*Type"). 2016-12-20 13:54:11 +00:00
whitequark c562ea784d Fix TcpRepr field visibility. 2016-12-20 13:44:41 +00:00
whitequark 3d5f47b89f Implement TCP representation printing. 2016-12-20 13:16:29 +00:00
whitequark 513923725e Implement TCP representation parsing and emission. 2016-12-20 12:52:33 +00:00
whitequark 31040bf0fc In Repr::emit, do not assume that the packet is pre-zeroed. 2016-12-20 09:41:08 +00:00
whitequark 9c922d0306 Implement TCP packet support. 2016-12-18 21:42:44 +00:00