summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-04-23 04:58:38 (GMT)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-04-23 04:58:38 (GMT)
commit6f0de2fb3a3c346cc98624c73d6dfd2858407b39 (patch)
treecab345591e745a99f5df5fd7d9051bc5de850758 /plugins/utils.c
parent6b891545ced74ddb7e419fe1d13c0118cc13c316 (diff)
downloadmonitoring-plugins-6f0de2fb3a3c346cc98624c73d6dfd2858407b39.tar.gz
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
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c31
1 files changed, 24 insertions, 7 deletions
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)
192} 192}
193 193
194/* from RFC-1035 194/* from RFC-1035
195 * 195*
196 * The labels must follow the rules for ARPANET host names. They must 196* The labels must follow the rules for ARPANET host names. They must
197 * start with a letter, end with a letter or digit, and have as interior 197* start with a letter, end with a letter or digit, and have as interior
198 * characters only letters, digits, and hyphen. There are also some 198* characters only letters, digits, and hyphen. There are also some
199 * restrictions on the length. Labels must be 63 characters or less. */ 199* restrictions on the length. Labels must be 63 characters or less.
200*
201* Then RFC-1123:
202*
203* 2.1 Host Names and Numbers
204*
205* The syntax of a legal Internet host name was specified in RFC-952
206* [DNS:4]. One aspect of host name syntax is hereby changed: the
207* restriction on the first character is relaxed to allow either a
208* letter or a digit. Host software MUST support this more liberal
209* syntax.
210*
211* Host software MUST handle host names of up to 63 characters and
212* SHOULD handle host names of up to 255 characters.
213*/
200 214
201int 215int
202is_hostname (char *s1) 216is_hostname (char *s1)
203{ 217{
204 if (!s1 || strlen (s1) > 63) { 218 if (!s1 || strlen (s1) > 255) {
205 return FALSE; 219 return FALSE;
206 } 220 }
221 /* if s1 contains anything but ALPHA, NUM, dash, or period*/
207 if (strcspn (s1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789-.") != 0) { 222 if (strcspn (s1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789-.") != 0) {
208 return FALSE; 223 return FALSE;
209 } 224 }
210 if (strspn (s1, "0123456789-.") == 1) { 225 /* or if s1 begins with dash or period */
226 if (strspn (s1, "-.") == 1) {
211 return FALSE; 227 return FALSE;
212 } 228 }
229 /* '..' and '.-' are not legal either */
213 while ((s1 = index (s1, '.'))) { 230 while ((s1 = index (s1, '.'))) {
214 s1++; 231 s1++;
215 if (strspn (s1, "0123456789-.") == 1) { 232 if (strspn (s1, "0123456789-.") == 1) {