From 6e66bcb23bff57c0dde49f466124a82505a3e7ce Mon Sep 17 00:00:00 2001 From: Li Wang Date: Tue, 3 Oct 2017 05:29:23 +0000 Subject: [PATCH] ceph_mon: warn on invalid port configuration It checks the validty of monitor port configuration in ceph.conf, and warns if necessary. Signed-off-by: Li Wang --- src/ceph_mon.cc | 4 +++- src/msg/msg_types.cc | 3 +++ src/msg/msg_types.h | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index edf262753ca..f334efd2cf0 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -635,7 +635,9 @@ int main(int argc, const char **argv) << " does not match monmap file" << std::endl << " continuing with monmap configuration" << dendl; } - } + } else + derr << "WARNING: invalid 'mon addr' config option" << std::endl + << " continuing with monmap configuration" << dendl; } } else { dout(0) << g_conf->name << " does not exist in monmap, will attempt to join an existing cluster" << dendl; diff --git a/src/msg/msg_types.cc b/src/msg/msg_types.cc index 28cedef1cb2..d1a53b03420 100644 --- a/src/msg/msg_types.cc +++ b/src/msg/msg_types.cc @@ -140,6 +140,9 @@ bool entity_addr_t::parse(const char *s, const char **end) // parse a port, too! p++; int port = atoi(p); + if (port > MAX_PORT_NUMBER) { + return false; + } set_port(port); while (*p && *p >= '0' && *p <= '9') p++; diff --git a/src/msg/msg_types.h b/src/msg/msg_types.h index 8a20ba0f060..a0d57de78d4 100644 --- a/src/msg/msg_types.h +++ b/src/msg/msg_types.h @@ -22,6 +22,8 @@ #include "include/blobhash.h" #include "include/encoding.h" +#define MAX_PORT_NUMBER 65535 + namespace ceph { class Formatter; } -- 2.47.3