Skip to content

Bounds-check int64→int32 budget conversions (CodeQL go/incorrect-integer-conversion) #11

Description

@prashar32

CodeQL reports two high-severity go/incorrect-integer-conversion alerts:

In loadBudget, parsed values are converted int64 → int32 without a range check:

b.Loops = int32(loops)      // line ~248
b.Seconds = int32(secs)     // line ~253

A value above math.MaxInt32 would silently overflow/wrap.

Proposed fix (standard approach)

  • Either parse directly with strconv.ParseInt(v, 10, 32), or clamp to [0, math.MaxInt32] before converting (envInt64 already rejects negatives). Apply the same guard anywhere else an int64 is narrowed to int32.
  • Add a test for an out-of-range value.

Alerts: /security/code-scanning/1 and /security/code-scanning/2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions