Skip to content

Commit

Permalink
Merge pull request #1209 from luhring/better-int32-checking
Browse files Browse the repository at this point in the history
fix(log): correct int32 bounds checking
  • Loading branch information
luhring authored Sep 25, 2024
2 parents b5c248c + 924a918 commit 46dc5ff
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cli
import (
"fmt"
"log/slog"
"math"
"os"

"github.com/chainguard-dev/clog/slag"
Expand All @@ -20,7 +21,7 @@ func New() *cobra.Command {
Short: "A CLI helper for developing Wolfi",
PersistentPreRunE: func(_ *cobra.Command, _ []string) error {
// Ensure level is within the int32 range
if int(level) < int(^int32(0)+1) || int(level) > int(int32(^uint32(0)>>1)) {
if int(level) < math.MinInt32 || int(level) > math.MaxInt32 {
return fmt.Errorf("log level out of range: %d", level)
}

Expand Down

0 comments on commit 46dc5ff

Please sign in to comment.