Repository: minio/minio (language: go)

Issue:
Internal error while force-deleting a bucket
## Situation
I had set up an HTTP based audit web-hook to a service that wasn't able to deal with the generated load. I already got some `deadline exceeded` errors during the auditing web-hooks, but that was to be expected. I aborted the warp tool and tried to delete the bucket using `mc rb local/warp-benchmark-bucket/ --force`. It failed, because of an internal error, and the Minio log showed the following:

```
panic: "DELETE /warp-benchmark-bucket/": runtime error: invalid memory address or nil pointer dereference
goroutine 427091 [running]:
runtime/debug.Stack()
        /usr/local/go/src/runtime/debug/stack.go:24 +0x5e
github.com/minio/minio/cmd.serverMain.func8.setCriticalErrorHandler.func2.1()
        /home/ramon/minio/minio/cmd/generic-handlers.go:568 +0x97
panic({0x288e320?, 0x645d360?})
        /usr/local/go/src/runtime/panic.go:914 +0x21f
github.com/minio/minio/cmd.objectAPIHandlers.DeleteBucketHandler({0xc0b7245800?}, {0x4d35180, 0xc09b2f2780}, 0xc0aa9dc300)
        /home/ramon/minio/minio/cmd/bucket-handlers.go:1664 +0x533
net/http.HandlerFunc.ServeHTTP(0x5435129?, {0x4d35180?, 0xc09b2f2780?}, 0x6aa02c?)
        /usr/local/go/src/net/http/server.go:2136 +0x29
github.com/minio/minio/cmd.s3APIMiddleware.func1.httpTraceAll.httpTrace.func4({0x4d35180, 0xc09b2f2780}, 0xc09b46e480?)
        /home/ramon/minio/minio/cmd/http-tracer.go:189 +0xef
net/http.HandlerFunc.ServeHTTP(0x646e940?, {0x4d35180?, 0xc09b2f2780?}, 0x4?)
        /usr/local/go/src/net/http/server.go:2136 +0x29
github.com/klauspost/compress/gzhttp.NewWrapper.func1.1({0x4d33b78, 0xc09b46e480}, 0xc0aa991da0?)
        /home/ramon/go/pkg/mod/github.com/klauspost/compress@v1.17.8/gzhttp/compress.go:497 +0x37d
net/http.HandlerFunc.ServeHTTP(0xc0aa8bb310?, {0x4d33b78?, 0xc09b46e480?}, 0x1?)
        /usr/local/go/src/net/http/server.go:2136 +0x29
github.com/minio/minio/cmd.s3APIMiddleware.func1.maxClients.func1({0x4d33b78, 0xc09b46e480}, 0xc0aa9dc300)
        /home/ramon/minio/minio/cmd/handler-api.go:343 +0x47e
net/http.HandlerFunc.ServeHTTP(0x64e6a70?, {0x4d33b78?, 0xc09b46e480?}, 0x5435156?)
        /usr/local/go/src/net/http/server.go:2136 +0x29
github.com/minio/minio/cmd.s3APIMiddleware.func1.collectAPIStats.func2({0x4d33b78, 0xc09b46e480}, 0xc0aa9dc300)
        /home/ramon/minio/minio/cmd/handler-utils.go:337 +0x4aa
github.com/minio/minio/cmd.s3APIMiddleware.func1({0x4d33b78, 0xc09b46e480}, 0x1b?)
        /home/ramon/minio/minio/cmd/api-router.go:246 +0x174
net/http.HandlerFunc.ServeHTTP(0xc0aa9c9140?, {0x4d33b78?, 0xc09b46e480?}, 0xc0aa8bd460?)
        /usr/local/go/src/net/http/server.go:2136 +0x29
```


Discussion / hints:
It looks like this method doesn't return a replication configuration: https://github.com/minio/minio/blob/1d03bea965e7bdee45a5eff1ee5fc6ba1a526580/cmd/bucket-replication.go#L82-L88

I guess that's okay, because I didn't have any replication enabled. It is called from this code: https://github.com/minio/minio/blob/1d03bea965e7bdee45a5eff1ee5fc6ba1a526580/cmd/bucket-handlers.go#L1657-L1667

There is no error returned and `rcfg` is set to nil. That's causing the second case statement to fail. It looks this only fails when force-deleting a bucket without replication enabled.

Fix patch:
diff --git a/cmd/bucket-handlers.go b/cmd/bucket-handlers.go
index 2edca90b9b986..9822e3e7e6e4d 100644
--- a/cmd/bucket-handlers.go
+++ b/cmd/bucket-handlers.go
@@ -1661,7 +1661,7 @@ func (api objectAPIHandlers) DeleteBucketHandler(w http.ResponseWriter, r *http.
 					writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrMethodNotAllowed), r.URL)
 					return
 				}
-			case rcfg.HasActiveRules("", true):
+			case rcfg != nil && rcfg.HasActiveRules("", true):
 				writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrMethodNotAllowed), r.URL)
 				return
 			}


Test patch: