prevent out-of-memory errors (#5674)

impose a maximum size on body of incoming HTTP requests and responses.
This commit is contained in:
Alessandro Ros
2026-04-19 21:39:08 +02:00
committed by GitHub
parent 3c7c45efa4
commit caeccdceff
10 changed files with 37 additions and 15 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
package api //nolint:revive
import (
"io"
"net/http"
"github.com/bluenviron/mediamtx/internal/conf"
@@ -18,7 +19,7 @@ func (a *API) onConfigPathDefaultsGet(ctx *gin.Context) {
func (a *API) onConfigPathDefaultsPatch(ctx *gin.Context) {
var p conf.OptionalPath
err := jsonwrapper.Decode(ctx.Request.Body, &p)
err := jsonwrapper.Decode(io.LimitReader(ctx.Request.Body, maxInboundConfigSize), &p)
if err != nil {
a.writeError(ctx, http.StatusBadRequest, err)
return