Skip to content

Commit b95aed5

Browse files
author
Reed Allman
authored
Merge pull request #335 from fnproject/sanitize-cl
fix neg content length
2 parents 0280df0 + 0f50e4b commit b95aed5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

api/server/runner.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ func (s *Server) serve(c *gin.Context, appName, path string) {
6969

7070
if model.Type == "async" {
7171
// TODO we should push this into GetCall somehow (CallOpt maybe) or maybe agent.Queue(Call) ?
72-
buf := bytes.NewBuffer(make([]byte, c.Request.ContentLength)[:0]) // TODO sync.Pool me
72+
contentLength := c.Request.ContentLength
73+
if contentLength < 128 { // contentLength could be -1 or really small, sanitize
74+
contentLength = 128
75+
}
76+
buf := bytes.NewBuffer(make([]byte, int(contentLength))[:0]) // TODO sync.Pool me
7377
_, err := buf.ReadFrom(c.Request.Body)
7478
if err != nil {
7579
handleErrorResponse(c, models.ErrInvalidPayload)

0 commit comments

Comments
 (0)