mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-06-06 23:57:21 +02:00
Fixed netstat underflow bug
- Fixed netstat sometime underflow to a large negative number bug
This commit is contained in:
parent
895ee1e53f
commit
de9d3bfb65
@ -212,6 +212,10 @@ func (n *NetStatBuffers) GetNetworkInterfaceStats() (int64, int64, error) {
|
|||||||
totalTx += counter.BytesSent
|
totalTx += counter.BytesSent
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert bytes to bits
|
// Convert bytes to bits with overflow check
|
||||||
|
const maxInt64 = int64(^uint64(0) >> 1)
|
||||||
|
if totalRx*8 > uint64(maxInt64) || totalTx*8 > uint64(maxInt64) {
|
||||||
|
return 0, 0, errors.New("overflow detected when converting uint64 to int64")
|
||||||
|
}
|
||||||
return int64(totalRx * 8), int64(totalTx * 8), nil
|
return int64(totalRx * 8), int64(totalTx * 8), nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user