Skip to content

Commit

Permalink
check for upper bound before coverting int into int32
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Avetisyan <[email protected]>
  • Loading branch information
havetisyan committed Dec 22, 2024
1 parent e1092ab commit 3977a16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions libs/go/sia/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"encoding/pem"
"fmt"
"log"
"math"
"os"
"os/exec"
"os/signal"
Expand Down Expand Up @@ -298,7 +299,7 @@ func registerSvc(svc options.Service, ztsUrl string, opts *options.Options) erro
Hostname: zts.DomainName(hostname),
Namespace: zts.SimpleName(opts.SpiffeNamespace),
}
if svc.ExpiryTime > 0 {
if svc.ExpiryTime > 0 && svc.ExpiryTime <= math.MaxInt32 {
expiryTime := int32(svc.ExpiryTime)
info.ExpiryTime = &expiryTime
}
Expand Down Expand Up @@ -416,7 +417,7 @@ func refreshSvc(svc options.Service, ztsUrl string, opts *options.Options) error
Hostname: zts.DomainName(hostname),
Namespace: zts.SimpleName(opts.SpiffeNamespace),
}
if svc.ExpiryTime > 0 {
if svc.ExpiryTime > 0 && svc.ExpiryTime <= math.MaxInt32 {
expiryTime := int32(svc.ExpiryTime)
info.ExpiryTime = &expiryTime
}
Expand Down
5 changes: 3 additions & 2 deletions libs/go/sia/aws/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"encoding/pem"
"fmt"
"log"
"math"
"os"
"os/exec"
"os/signal"
Expand Down Expand Up @@ -297,7 +298,7 @@ func registerSvc(svc options.Service, data *attestation.AttestationData, ztsUrl
Hostname: zts.DomainName(hostname),
Namespace: zts.SimpleName(opts.SpiffeNamespace),
}
if svc.ExpiryTime > 0 {
if svc.ExpiryTime > 0 && svc.ExpiryTime <= math.MaxInt32 {
expiryTime := int32(svc.ExpiryTime)
info.ExpiryTime = &expiryTime
}
Expand Down Expand Up @@ -411,7 +412,7 @@ func refreshSvc(svc options.Service, data *attestation.AttestationData, ztsUrl s
Hostname: zts.DomainName(hostname),
Namespace: zts.SimpleName(opts.SpiffeNamespace),
}
if svc.ExpiryTime > 0 {
if svc.ExpiryTime > 0 && svc.ExpiryTime <= math.MaxInt32 {
expiryTime := int32(svc.ExpiryTime)
info.ExpiryTime = &expiryTime
}
Expand Down

0 comments on commit 3977a16

Please sign in to comment.