From: Li Wang Date: Tue, 3 Oct 2017 05:29:23 +0000 (+0000) Subject: ceph_mon: warn on invalid port configuration X-Git-Tag: v13.0.1~676^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F18073%2Fhead;p=ceph.git 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 --- 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; }