summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/command.c10
-rw-r--r--lib/command.h11
-rw-r--r--lib/libfrr.c2
-rw-r--r--lib/northbound.c2
-rw-r--r--vtysh/vtysh.c2
-rw-r--r--vtysh/vtysh_config.c4
6 files changed, 25 insertions, 6 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/libfrr.c b/lib/libfrr.c
index 15de96feee..c60e26085f 100644
--- a/lib/libfrr.c
+++ b/lib/libfrr.c
@@ -61,7 +61,7 @@ static char pidfile_default[512];
#ifdef HAVE_SQLITE3
static char dbfile_default[512];
#endif
-static char vtypath_default[256];
+static char vtypath_default[512];
bool debug_memstats_at_exit = false;
static bool nodetach_term, nodetach_daemon;
diff --git a/lib/northbound.c b/lib/northbound.c
index dbf90c58d4..8a5cd0ef14 100644
--- a/lib/northbound.c
+++ b/lib/northbound.c
@@ -777,7 +777,7 @@ static void nb_log_callback(const enum nb_event event,
zlog_debug(
"northbound callback: event [%s] op [%s] xpath [%s] value [%s]",
nb_event_name(event), nb_operation_name(operation), xpath,
- value);
+ value ? value : "(NULL)");
}
/*
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index 1ab70eeed2..baf77d1cb7 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -3438,7 +3438,7 @@ void vtysh_readline_init(void)
char *vtysh_prompt(void)
{
- static char buf[100];
+ static char buf[512];
snprintf(buf, sizeof buf, cmd_prompt(vty->node), cmd_hostname_get());
return buf;
diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c
index cf94ab643a..9c2de0f62b 100644
--- a/vtysh/vtysh_config.c
+++ b/vtysh/vtysh_config.c
@@ -521,10 +521,10 @@ int vtysh_read_config(const char *config_default_dir)
*/
void vtysh_config_write(void)
{
- char line[81];
+ char line[512];
if (cmd_hostname_get()) {
- sprintf(line, "hostname %s", cmd_hostname_get());
+ snprintf(line, sizeof(line), "hostname %s", cmd_hostname_get());
vtysh_config_parse_line(NULL, line);
}