mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-22 22:05:02 +03:00
fix(service): keep chunk capacity math from overflowing
chunkStrings/chunkInts sized their result with (len+size-1)/size, so a size near MaxInt wrapped negative and make panicked with "cap out of range"; count the chunks with div+remainder instead. NormalizeUDPHop's len-hops+1 is bounded by len(masks) since hops >= 1, so cap at that. Resolves CodeQL go/allocation-size-overflow alerts #119 and #120.
This commit is contained in:
@@ -51,7 +51,7 @@ func NormalizeUDPHop(finalmask any) bool {
|
||||
if last < 0 || (hops == 1 && last == len(masks)-1) {
|
||||
return false
|
||||
}
|
||||
kept := make([]any, 0, len(masks)-hops+1)
|
||||
kept := make([]any, 0, len(masks)) // hops >= 1, so the re-appended hop still fits
|
||||
for _, mask := range masks {
|
||||
if !isUDPHopMask(mask) {
|
||||
kept = append(kept, mask)
|
||||
|
||||
Reference in New Issue
Block a user