Skip to content

Commit c541171

Browse files
bug: fix integer type conversion (#946)
1 parent 41718d4 commit c541171

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
IMPROVEMENTS:
44
* build: Updated to Go 1.22.6 and alpine to 3.20 [[GH-943](https://github.com/hashicorp/nomad-autoscaler/pull/943)]
55

6+
BUG FIXES:
7+
* security: Fix incorrect conversion between integer types [[GH-946](https://github.com/hashicorp/nomad-autoscaler/pull/946)]
8+
69
## 0.4.4 (June 4, 2024)
710

811
IMPROVEMENTS:

policy/handler.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,16 @@ func (h *Handler) handleTick(ctx context.Context, policy *sdk.ScalingPolicy) (*s
276276
// Convert the last event string. If an error occurs, just log and
277277
// continue with the evaluation. A malformed timestamp shouldn't mean
278278
// we skip scaling.
279-
lastTS, err := strconv.ParseUint(ts, 10, 64)
279+
lastTS, err := strconv.ParseInt(ts, 10, 64)
280280
if err != nil {
281-
h.log.Error("failed to parse last event timestamp as uint64", "error", err)
281+
h.log.Error("failed to parse last event timestamp as int64", "error", err)
282282
return eval, nil
283283
}
284284

285285
// Calculate the remaining time period left on the cooldown. If this is
286286
// cooldownIgnoreTime or below, we do not need to enter cooldown. Reasoning
287287
// on ignoring small variations can be seen within GH-138.
288-
cdPeriod := h.calculateRemainingCooldown(policy.Cooldown, curTime, int64(lastTS))
288+
cdPeriod := h.calculateRemainingCooldown(policy.Cooldown, curTime, lastTS)
289289
if cdPeriod <= cooldownIgnoreTime {
290290
return eval, nil
291291
}

0 commit comments

Comments
 (0)