Skip to content

Commit f2865d0

Browse files
authored
fix: guard ttl loading against int overflow (#292)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 26aaea7 commit f2865d0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

internal/indexer/indexer.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Blink Labs Software
1+
// Copyright 2025 Blink Labs Software
22
//
33
// Use of this source code is governed by an MIT-style
44
// license that can be found in the LICENSE file or at
@@ -10,6 +10,7 @@ import (
1010
"encoding/hex"
1111
"fmt"
1212
"log/slog"
13+
"math"
1314
"os"
1415
"strings"
1516
"time"
@@ -369,7 +370,10 @@ func (i *Indexer) handleEventOutputDns(
369370
Rhs: string(record.Rhs),
370371
}
371372
if record.Ttl.HasValue() {
372-
tmpRecord.Ttl = int(record.Ttl.Value)
373+
if record.Ttl.Value > math.MaxInt {
374+
return fmt.Errorf("record ttl value out of bounds")
375+
}
376+
tmpRecord.Ttl = int(record.Ttl.Value) // #nosec G115
373377
}
374378
tmpRecords = append(tmpRecords, tmpRecord)
375379
}

0 commit comments

Comments
 (0)