Skip to content

Commit

Permalink
Avoid integer overrun in NIOHTTPResponsiveness (#247)
Browse files Browse the repository at this point in the history
We use 8*10^9 in `NIOHTTPResponsiveness` however this number will
overrun the integer size on platforms with 32-bit pointer-width such as
watchOS.

This change drops down to use 1*10^9 on such platforms.
  • Loading branch information
rnro authored Jan 31, 2025
1 parent c96e658 commit 926c3e1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/NIOHTTPResponsiveness/ResponsivenessConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ public struct ResponsivenessConfigURLs: Codable, Hashable, Sendable {
case uploadURL = "upload_url"
}

static var largeDownloadSize: Int { 8 * 1_000_000_000 } // 8 * 10^9
#if _pointerBitWidth(_32)
static var largeDownloadSize: Int { 1_000_000_000 } // 1 * 10^9
#else
static var largeDownloadSize: Int { 8_000_000_000 } // 8 * 10^9
#endif
static var smallDownloadSize: Int { 1 }

public init(scheme: String, authority: String) {
Expand Down

0 comments on commit 926c3e1

Please sign in to comment.