diff --git a/pkg/envexec/file_collect.go b/pkg/envexec/file_collect.go index b9d4765..4509f61 100644 --- a/pkg/envexec/file_collect.go +++ b/pkg/envexec/file_collect.go @@ -1,6 +1,7 @@ package envexec import ( + "fmt" "io/ioutil" "os" @@ -24,6 +25,17 @@ func copyOutAndCollect(m Environment, c *Cmd, ptc []pipeCollector) (map[string]f } defer cf.Close() + // check size limit + if c.CopyOutMax != 0 { + stat, err := cf.Stat() + if err != nil { + return err + } + if s := stat.Size(); s > int64(c.CopyOutMax) { + return fmt.Errorf("File %s have size %d exceeded the limit %d", n, s, c.CopyOutMax) + } + } + c, err := ioutil.ReadAll(cf) if err != nil { return err