server(filesystem): handle writing empty files

Fixes https://github.com/pterodactyl/panel/issues/5038

Signed-off-by: Matthew Penner <me@matthewp.io>
This commit is contained in:
Matthew Penner
2024-03-17 14:46:05 -06:00
parent a877305202
commit 1c5ddcd20c
2 changed files with 14 additions and 7 deletions

View File

@@ -239,7 +239,8 @@ func postServerWriteFile(c *gin.Context) {
return
}
if c.Request.ContentLength < 1 {
// A content length of -1 means the actual length is unknown.
if c.Request.ContentLength == -1 {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{
"error": "Missing Content-Length",
})