mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-10-22 10:32:27 +00:00
Merge pull request #2593 from pobregat0/transit-bandwidth-overflow
Fix overflow in tunnel build bandwidth options check
This commit is contained in:
1 file changed
+2
-2
@@ -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
|
||||
|
||||
Reference in new issue
Block a user