drive: fix index out of bounds when parsing request local paths (#15517)

Fix the index out of bound panic when a request is made to the local
fileserver mux with a valid secret-token, but missing share name.

Example error:

    http: panic serving 127.0.0.1:40974: runtime error: slice bounds out of range [2:1]

Additionally, we document the edge case behavior of utilities that
this fileserver mux depends on.

Signed-off-by: Craig Hesling <craig@hesling.com>
This commit is contained in:
Craig Hesling
2025-04-09 14:12:23 -07:00
committed by GitHub
parent d486ea388d
commit b9277ade1f
4 changed files with 79 additions and 4 deletions
+4
View File
@@ -142,6 +142,10 @@ func (s *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
if len(parts) < 2 {
w.WriteHeader(http.StatusBadRequest)
return
}
r.URL.Path = shared.Join(parts[2:]...)
share := parts[1]
s.sharesMu.RLock()