mirror of
https://github.com/pgsty/minio.git
synced 2026-07-23 06:00:24 +03:00
handlers: Handle crash if r.URL.Path is empty. (#3554)
URL paths can be empty and not have preceding separator, we do not yet know the conditions this can happen inside Go http server. This patch is to ensure that we do not crash ourselves under conditions where r.URL.Path may be empty. Fixes #3553
This commit is contained in:
+1
-12
@@ -311,18 +311,7 @@ var notimplementedObjectResourceNames = map[string]bool{
|
||||
|
||||
// Resource handler ServeHTTP() wrapper
|
||||
func (h resourceHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// Skip the first element which is usually '/' and split the rest.
|
||||
splits := strings.SplitN(r.URL.Path[1:], "/", 2)
|
||||
|
||||
// Save bucketName and objectName extracted from url Path.
|
||||
var bucketName, objectName string
|
||||
if len(splits) == 1 {
|
||||
bucketName = splits[0]
|
||||
}
|
||||
if len(splits) == 2 {
|
||||
bucketName = splits[0]
|
||||
objectName = splits[1]
|
||||
}
|
||||
bucketName, objectName := urlPath2BucketObjectName(r.URL)
|
||||
|
||||
// If bucketName is present and not objectName check for bucket level resource queries.
|
||||
if bucketName != "" && objectName == "" {
|
||||
|
||||
Reference in New Issue
Block a user