Fix faulty handling of named pipes; closes pterodactyl/panel#4059

This commit is contained in:
DaneEveritt
2022-05-07 15:53:08 -04:00
parent 6c98a955e3
commit 1d197714df
4 changed files with 35 additions and 102 deletions

View File

@@ -37,6 +37,15 @@ func getServerFileContents(c *gin.Context) {
return
}
defer f.Close()
// Don't allow a named pipe to be opened.
//
// @see https://github.com/pterodactyl/panel/issues/4059
if st.Mode()&os.ModeNamedPipe != 0 {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{
"error": "Cannot open files of this type.",
})
return
}
c.Header("X-Mime-Type", st.Mimetype)
c.Header("Content-Length", strconv.Itoa(int(st.Size())))