Skip to content

Commit

Permalink
tap_user: Drop fragmented IPv4 frames
Browse files Browse the repository at this point in the history
- Fragmentation is not supported yet, so drop fragmented packets instead of erroneously handling them as complete
- It is unlikely that fragmentation will be ever needed (Internet routers & hosts widely drop fragmented packets as well)
  • Loading branch information
LekKit authored Feb 29, 2024
1 parent 9e4c793 commit 073ff57
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/devices/tap_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,11 @@ static void handle_ipv4(tap_dev_t* tap, const uint8_t* buffer, size_t size)
}
size_t total_length = read_uint16_be_m(buffer + 2);
size_t header_length = (buffer[0] & 0xF) << 2;
uint16_t frag_flags = read_uint16_be_m(buffer + 6);
if (unlikely(frag_flags & 0x3FFF)) {
// This is a fragmented frame
return;
}
if (unlikely(size < total_length)) {
// Encoded size exceeds frame size
return;
Expand Down

0 comments on commit 073ff57

Please sign in to comment.