Skip to content

Commit

Permalink
protect against overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
n-g committed Jul 31, 2024
1 parent 8ab201f commit f1b1f4f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/build/buildkit/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"namespacelabs.dev/foundation/std/tasks/idtypes"
)

const maxJsonEventLength = 64 * 1024 * 1024

var TaskOutputBuildkitJsonLog = tasks.Output("buildkit.json", "application/json+fn.buildkit")

var UsePlaintextLogging = false
Expand Down Expand Up @@ -244,6 +246,11 @@ func pushJsonEvent(w io.Writer, ev jsonEvent) error {
if err != nil {
return err
}

if len(p) > maxJsonEventLength {
return fmt.Errorf("json event too large")
}

// Make a space for a newline, easier to parse.
pline := make([]byte, len(p)+1)
copy(pline, p)
Expand Down

0 comments on commit f1b1f4f

Please sign in to comment.