Skip to content

Commit b776932

Browse files
Fixing issue #430 - ephemeralRoomIdMinimum would overflow on 32 bit systems (#432)
Changed: - Changed the roomIdMin32Bit variable from 1,000,000,000 to 1,000,000
1 parent 9e7e60e commit b776932

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

internal/rooms/ephemeral.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import (
1111
)
1212

1313
const (
14-
ephemeralChunksLimit = 100 // The maximum number of ephemeral chunks that can be created
15-
ephemeralChunkSize = 250 // The maximum quantity of ephemeral room's that can be copied/created in a given chunk.
16-
roomIdMin32Bit = 1000000000 // 1,000,000,000
14+
ephemeralChunksLimit = 100 // The maximum number of ephemeral chunks that can be created
15+
ephemeralChunkSize = 250 // The maximum quantity of ephemeral room's that can be copied/created in a given chunk.
16+
roomIdMin32Bit = 1000000 // 1,000,000 - Safe for 32-bit systems (was 1,000,000,000 which overflows when multiplied by 1000)
1717
)
1818

1919
var (
20-
ephemeralRoomIdMinimum = roomIdMin32Bit // 1,000,000,000 is assuming 32 bit. the init() function may override this value.
20+
ephemeralRoomIdMinimum = roomIdMin32Bit // 1,000,000 is assuming 32 bit. the init() function may override this value to 1,000,000,000 on 64-bit systems.
2121
ephemeralRoomChunks = [ephemeralChunksLimit][]int{} // map of ranges to actual rooms. If empty, slot is available.
2222
originalRoomIdLookups = map[int]int{} // a map of ephemeralId's to their original RoomId's, for special purposes
2323
// errors
@@ -232,6 +232,6 @@ func GetOriginalRoom(roomId int) int {
232232

233233
func init() {
234234
if math.MaxInt > ephemeralRoomIdMinimum*1000 {
235-
ephemeralRoomIdMinimum = ephemeralRoomIdMinimum * 1000 // 1,000,000,000 => // 1,000,000,000,000
235+
ephemeralRoomIdMinimum = ephemeralRoomIdMinimum * 1000 // 1,000,000 => 1,000,000,000 on 64-bit systems
236236
}
237237
}

0 commit comments

Comments
 (0)