diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/command.c | 10 | ||||
| -rw-r--r-- | lib/command.h | 11 | ||||
| -rw-r--r-- | lib/zclient.c | 7 | ||||
| -rw-r--r-- | lib/zclient.h | 2 |
4 files changed, 26 insertions, 4 deletions
diff --git a/lib/command.c b/lib/command.c index 5335969fbc..e5e0623163 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1962,7 +1962,15 @@ DEFUN (config_hostname, struct cmd_token *word = argv[1]; if (!isalnum((int)word->arg[0])) { - vty_out(vty, "Please specify string starting with alphabet\n"); + vty_out(vty, + "Please specify string starting with alphabet or number\n"); + return CMD_WARNING_CONFIG_FAILED; + } + + /* With reference to RFC 1123 Section 2.1 */ + if (strlen(word->arg) > HOSTNAME_LEN) { + vty_out(vty, "Hostname length should be less than %d chars\n", + HOSTNAME_LEN); return CMD_WARNING_CONFIG_FAILED; } diff --git a/lib/command.h b/lib/command.h index d96ec97e67..d6c41e0824 100644 --- a/lib/command.h +++ b/lib/command.h @@ -37,6 +37,17 @@ extern "C" { DECLARE_MTYPE(HOST) DECLARE_MTYPE(COMPLETION) +/* + * From RFC 1123 (Requirements for Internet Hosts), Section 2.1 on hostnames: + * One aspect of host name syntax is hereby changed: the restriction on + * the first character is relaxed to allow either a letter or a digit. + * Host software MUST support this more liberal syntax. + * + * Host software MUST handle host names of up to 63 characters and + * SHOULD handle host names of up to 255 characters. + */ +#define HOSTNAME_LEN 255 + /* Host configuration variable */ struct host { /* Host name of this router. */ diff --git a/lib/zclient.c b/lib/zclient.c index 0972590ca6..e9b4f5a58b 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -62,10 +62,13 @@ struct zclient *zclient_new(struct thread_master *master, struct zclient_options *opt) { struct zclient *zclient; + size_t stream_size = + MAX(ZEBRA_MAX_PACKET_SIZ, sizeof(struct zapi_route)); + zclient = XCALLOC(MTYPE_ZCLIENT, sizeof(struct zclient)); - zclient->ibuf = stream_new(ZEBRA_MAX_PACKET_SIZ); - zclient->obuf = stream_new(ZEBRA_MAX_PACKET_SIZ); + zclient->ibuf = stream_new(stream_size); + zclient->obuf = stream_new(stream_size); zclient->wb = buffer_new(0); zclient->master = master; diff --git a/lib/zclient.h b/lib/zclient.h index 09f0acad84..c61c8d4226 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -39,7 +39,7 @@ #include "mlag.h" /* For input/output buffer to zebra. */ -#define ZEBRA_MAX_PACKET_SIZ 16384 +#define ZEBRA_MAX_PACKET_SIZ 16384U /* Zebra header size. */ #define ZEBRA_HEADER_SIZE 10 |
