Skip to content

🎧 Your Personal Streaming Service

Fix GO-S2114 security issue

Deluan2a3cd08f201d
diff --git a/consts/consts.go b/consts/consts.go
index 63cf3e09d..2942de273 100644
--- a/consts/consts.go
+++ b/consts/consts.go
@@ -41,6 +41,8 @@ const (
RequestThrottleBacklogLimit = 100
RequestThrottleBacklogTimeout = time.Minute
+ ServerReadHeaderTimeout = 3 * time.Second
+
ArtistInfoTimeToLive = 24 * time.Hour
I18nFolder = "i18n"
diff --git a/server/server.go b/server/server.go
index d59f5102f..7a7f8d47c 100644
--- a/server/server.go
+++ b/server/server.go
@@ -45,7 +45,12 @@ var startTime = time.Now()
func (s *Server) Run(addr string) error {
s.MountRouter("WebUI", consts.URLPathUI, s.frontendAssetsHandler())
log.Info("Navidrome server is ready!", "address", addr, "startupTime", time.Since(startTime))
- return http.ListenAndServe(addr, s.router)
+ server := &http.Server{
+ Addr: addr,
+ ReadHeaderTimeout: consts.ServerReadHeaderTimeout,
+ }
+
+ return server.ListenAndServe()
}
func (s *Server) initRoutes() {