summaryrefslogtreecommitdiff
path: root/lib/command.h
diff options
context:
space:
mode:
authorLakshman Krishnamoorthy <lkrishnamoor@vmware.com>2019-05-30 14:56:55 -0700
committerLakshman Krishnamoorthy <lkrishnamoor@vmware.com>2019-05-31 10:52:33 -0700
commit63e653a21f59a17810d597ec35b20fb13bae6692 (patch)
treea9927f2c17804c1eb815ceef886c4f9ba866252b /lib/command.h
parent979dd989c46c318ad489d3be9219383ba19980ae (diff)
lib: crash when FRR hostname length > 80 chars
Although the RFC states hostname length should be < 255 chars, FRR allows infinite length technically. However, when you try to set a hostname > 80 chars, you would immediately notice a crash. RCA: Crash due to buffer overflow. Large buffer sprintf'd into smaller buffer. Usage of sprintf function instead of snprintf which is safer. Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
Diffstat (limited to 'lib/command.h')
-rw-r--r--lib/command.h11
1 files changed, 11 insertions, 0 deletions
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. */