Skip to content

Commit 2a733b6

Browse files
committed
fix: resolve gosec integer overflow warning in appendInt
Use strconv.AppendInt instead of manual conversion to avoid integer overflow when converting int64 to uint64
1 parent 8f167dc commit 2a733b6

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

internal/flashduty/log.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,8 @@ func fmtAny(v any) string {
205205

206206
// appendInt appends an int64 to the buffer.
207207
func appendInt(buf []byte, x int64) []byte {
208-
if x < 0 {
209-
buf = append(buf, '-')
210-
x = -x
211-
}
212-
return appendUint(buf, uint64(x))
208+
// Use strconv.AppendInt to avoid integer overflow issues
209+
return strconv.AppendInt(buf, x, 10)
213210
}
214211

215212
// appendUint appends a uint64 to the buffer.

0 commit comments

Comments
 (0)