From 41a3a9e402bf138c3f7e06b6a609961dd5ffff36 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Wed, 23 Nov 2016 02:01:15 +0100 Subject: [PATCH] server: forbid zero port in address flag since it confuses clients and (#3318) --- cmd/server-main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/server-main.go b/cmd/server-main.go index 3c957b241..8862209e7 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -369,6 +369,12 @@ func serverMain(c *cli.Context) { // Check if requested port is available. host, portStr, err := net.SplitHostPort(serverAddr) fatalIf(err, "Unable to parse %s.", serverAddr) + if portStr == "0" || portStr == "" { + // Port zero or empty means use requested to choose any freely available + // port. Avoid this since it won't work with any configured clients, + // can lead to serious loss of availability. + fatalIf(errInvalidArgument, "Invalid port `%s`, please use `--address` to pick a specific port", portStr) + } globalMinioHost = host // Check if requested port is available.