From 75492514ca23ea4ed83f870d38f626d955e4d53c Mon Sep 17 00:00:00 2001
From: zzz <zzz@i2pmail.org>
Date: Tue, 5 Apr 2022 07:55:28 -0400
Subject: [PATCH] SSU: Fix packet-too-large check in UDPSender

---
 router/java/src/net/i2p/router/transport/udp/UDPSender.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/router/java/src/net/i2p/router/transport/udp/UDPSender.java b/router/java/src/net/i2p/router/transport/udp/UDPSender.java
index 1c1310bd65..9776bfcff0 100644
--- a/router/java/src/net/i2p/router/transport/udp/UDPSender.java
+++ b/router/java/src/net/i2p/router/transport/udp/UDPSender.java
@@ -193,7 +193,8 @@ class UDPSender {
     public void add(UDPPacket packet) {
         if (packet == null || !_keepRunning) return;
         int psz = packet.getPacket().getLength();
-        if (psz > PeerState2.MAX_MTU) {
+        // minus IP header and UDP header, assume IPv4, this is just a quick check
+        if (psz > PeerState2.MAX_MTU - 28) {
             _log.error("Dropping large UDP packet " + psz + " bytes: " + packet, new Exception());
             return;
         }
-- 
GitLab