From 6f0de2fb3a3c346cc98624c73d6dfd2858407b39 Mon Sep 17 00:00:00 2001 From: Karl DeBisschop Date: Wed, 23 Apr 2003 04:58:38 +0000 Subject: update to RFC1123 hostname specs git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/branches/release-1.3.0@498 f882894a-f735-0410-b71e-b25c423dba1c diff --git a/plugins/check_http.c b/plugins/check_http.c index 856acde..d13050a 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -187,7 +187,7 @@ struct timeval tv; #define URI_PATH "%[/a-zA-Z0-9._-=@,]" enum { - MAX_IPV4_HOSTLENGTH = 64, + MAX_IPV4_HOSTLENGTH = 255, HTTP_PORT = 80, HTTPS_PORT = 443 }; @@ -734,7 +734,7 @@ check_http (void) asprintf (&orig_url, "%s", server_url); pos = header; while (pos) { - server_address = realloc (server_address, MAX_IPV4_HOSTLENGTH); + server_address = realloc (server_address, MAX_IPV4_HOSTLENGTH + 1); if (server_address == NULL) terminate (STATE_UNKNOWN, "HTTP UNKNOWN: could not allocate server_address"); diff --git a/plugins/utils.c b/plugins/utils.c index aaa9fe5..d06978f 100644 --- a/plugins/utils.c +++ b/plugins/utils.c @@ -192,24 +192,41 @@ is_dotted_quad (char *address) } /* from RFC-1035 - * - * The labels must follow the rules for ARPANET host names. They must - * start with a letter, end with a letter or digit, and have as interior - * characters only letters, digits, and hyphen. There are also some - * restrictions on the length. Labels must be 63 characters or less. */ +* +* The labels must follow the rules for ARPANET host names. They must +* start with a letter, end with a letter or digit, and have as interior +* characters only letters, digits, and hyphen. There are also some +* restrictions on the length. Labels must be 63 characters or less. +* +* Then RFC-1123: +* +* 2.1 Host Names and Numbers +* +* The syntax of a legal Internet host name was specified in RFC-952 +* [DNS:4]. 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. +*/ int is_hostname (char *s1) { - if (!s1 || strlen (s1) > 63) { + if (!s1 || strlen (s1) > 255) { return FALSE; } + /* if s1 contains anything but ALPHA, NUM, dash, or period*/ if (strcspn (s1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789-.") != 0) { return FALSE; } - if (strspn (s1, "0123456789-.") == 1) { + /* or if s1 begins with dash or period */ + if (strspn (s1, "-.") == 1) { return FALSE; } + /* '..' and '.-' are not legal either */ while ((s1 = index (s1, '.'))) { s1++; if (strspn (s1, "0123456789-.") == 1) { -- cgit v0.10-9-g596f