Skip to content

Commit 649a6f8

Browse files
authored
Merge pull request #10 from FarisZR/alert-autofix-1
Fix potential overflow in size computation for allocation
2 parents cbb25e7 + fce882d commit 649a6f8

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

internal/journald/journald.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package journald
22

33
import (
44
"errors"
5+
"fmt"
6+
"math"
57
"sync/atomic"
68
"syscall"
79
)
@@ -49,6 +51,10 @@ func Emit(eventType, message string, priority Priority, fields Fields) error {
4951
return nil
5052
}
5153

54+
if len(fields) > math.MaxInt-3 {
55+
return fmt.Errorf("too many fields in journald entry: %d > %d", len(fields), math.MaxInt-3)
56+
}
57+
5258
payload := make(Fields, len(fields)+3)
5359
for k, v := range fields {
5460
payload[k] = v

0 commit comments

Comments
 (0)