Private
Public Access
1
0

fix(db): use int for netspeed_active to prevent overflow
All checks were successful
continuous-integration/drone/push Build is passing

GetZoneStatsData and GetZoneStatsV2's netspeed_active values can
exceed 2 billion, causing 32-bit integer overflow. Changed from
int32/uint32 to int (64-bit on modern systems) to handle large
network speed totals.

- Update sqlc column overrides to use int type
- Fix type compatibility in dnsanswers.go zoneTotals map
- Regenerate database code with new types

Fixes https://community.ntppool.org/t/error-message-displayed-on-the-monitoring-score-page/4063
This commit is contained in:
2025-09-21 00:08:21 -07:00
parent 02a6f587bb
commit 196f90a2b9
4 changed files with 10 additions and 6 deletions

View File

@@ -123,7 +123,7 @@ func (srv *Server) dnsAnswers(c echo.Context) error {
return c.String(http.StatusInternalServerError, err.Error())
}
zoneTotals := map[string]int32{}
zoneTotals := map[string]int{}
for _, z := range zoneStats {
zn := z.ZoneName
@@ -145,7 +145,7 @@ func (srv *Server) dnsAnswers(c echo.Context) error {
if zt == 0 {
// if the recorded netspeed for the zone was zero, assume it's at least
// this servers worth instead. Otherwise the Netspeed gets to be 'infinite'.
zt = int32(serverNetspeed)
zt = int(serverNetspeed)
}
cc.Netspeed = (pointBasis / float64(zt)) * float64(serverNetspeed)
}