fix(api): Check MaxRetries integer bounds

This commit is contained in:
Hugo committed 2024-08-21 13:55:58 +01:00
1 parent 8e95a7eb86
commit 6f370c1189
2 files changed
+79

No files matched your search

+7
View File
@@ -11,6 +11,7 @@ import (
"errors"
"fmt"
"io"
"math"
"net"
"net/http"
"net/url"
@@ -308,6 +309,12 @@ func (c *Config) ReadEnvironment() error {
if err != nil {
return err
}
// maxRetries is a 32-bit unsigned integer stored inside an uint64.
// c.MaxRetries is a signed integer that is at least 32 bits in size.
// Check bounds against lowest denominator before casting.
if maxRetries > math.MaxInt32 {
return fmt.Errorf("max retries must be less than or equal to %d", math.MaxInt32)
}
c.MaxRetries = int(maxRetries)
}