[mirror] Scalable static site server for Git forges (like GitHub Pages)

Check for overflow when calculating size of zip

authored by David Leadbeater and committed by whitequark.org 86845f25 7f112a76

Changed files
+6
src
+6
src/extract.go
··· 9 9 "errors" 10 10 "fmt" 11 11 "io" 12 + "math" 12 13 "os" 13 14 "strings" 14 15 ··· 174 175 // Detect and defuse zipbombs. 175 176 var totalSize uint64 176 177 for _, file := range archive.File { 178 + if totalSize+file.UncompressedSize64 < totalSize { 179 + // Would overflow 180 + totalSize = math.MaxUint64 181 + break 182 + } 177 183 totalSize += file.UncompressedSize64 178 184 } 179 185 if totalSize > config.Limits.MaxSiteSize.Bytes() {