From 1e89ec5759ab03b9f6bed063968e5de195a72524 Mon Sep 17 00:00:00 2001 From: PobreGato <315121269+pobregat0@users.noreply.github.com> Date: Mon, 12 Oct 2026 21:28:29 -0400 Subject: [PATCH] fix overflow in tunnel build bandwidth options check --- libi2pd/TransitTunnel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libi2pd/TransitTunnel.cpp b/libi2pd/TransitTunnel.cpp index 589681bc..f6aaf08f 100644 --- a/libi2pd/TransitTunnel.cpp +++ b/libi2pd/TransitTunnel.cpp @@ -375,7 +375,7 @@ namespace tunnel { bwLimit = i2p::context.GetBandwidthLimit ()*1024; // in bytes bwUse = i2p::transport::transports.GetTransitBandwidth (); - if (bw*1024 + bwUse > bwLimit) + if ((uint64_t)bw*1024 + bwUse > bwLimit) // bw comes from the request, 32-bit product overflows retCode = 30; } if (!retCode && buildOptions.Get (TRANSIT_TUNNEL_REQUESTED_BANDWIDTH, bw)) @@ -387,7 +387,7 @@ namespace tunnel if (bwUse < bwLimit) { availableBandwidth = bwLimit - bwUse; - if (bw*1024 > availableBandwidth) + if ((uint64_t)bw*1024 > availableBandwidth) availableBandwidth /= 1024; else availableBandwidth = bw; // reply with requested bandwidth