summaryrefslogtreecommitdiff
path: root/sbin/dhclient/dhclient.c
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2005-04-02 16:41:10 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2005-04-02 16:41:10 +0000
commitd3201be4f265e4055a4d183ffd6b1da41db87ec1 (patch)
treef32cd58de947ce0cf17afcba8fd177277a3cd465 /sbin/dhclient/dhclient.c
parentdaad97102a0a4a1b9e898895fee50c592e258adc (diff)
allow _ in hostnames, but complain since this is not legal, but there is
no point in punishing openbsd users in fucked up networks From: Michael Knudsen <e@molioner.dk> with input from theo and me
Diffstat (limited to 'sbin/dhclient/dhclient.c')
-rw-r--r--sbin/dhclient/dhclient.c41
1 files changed, 16 insertions, 25 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index ef353c43724..b684c8b979a 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.63 2005/02/06 17:10:13 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.64 2005/04/02 16:41:09 henning Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -53,22 +53,11 @@
* purpose.
*/
+#include <ctype.h>
+
#include "dhcpd.h"
#include "privsep.h"
-#define PERIOD 0x2e
-#define hyphenchar(c) ((c) == 0x2d)
-#define bslashchar(c) ((c) == 0x5c)
-#define periodchar(c) ((c) == PERIOD)
-#define asterchar(c) ((c) == 0x2a)
-#define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) || \
- ((c) >= 0x61 && (c) <= 0x7a))
-#define digitchar(c) ((c) >= 0x30 && (c) <= 0x39)
-
-#define borderchar(c) (alphachar(c) || digitchar(c))
-#define middlechar(c) (borderchar(c) || hyphenchar(c))
-#define domainchar(c) ((c) > 0x20 && (c) < 0x7f)
-
#define CLIENT_PATH "PATH=/usr/bin:/usr/sbin:/bin:/sbin"
time_t cur_time;
@@ -2251,24 +2240,26 @@ check_option(struct client_lease *l, int option)
}
int
-res_hnok(const char *dn)
+res_hnok(const char *name)
{
- int pch = PERIOD, ch = *dn++;
+ const char *dn = name;
+ int pch = '.', ch = *dn++;
+ int warn = 0;
while (ch != '\0') {
int nch = *dn++;
- if (periodchar(ch)) {
+ if (ch == '.') {
;
- } else if (periodchar(pch)) {
- if (!borderchar(ch))
+ } else if (pch == '.' || nch == '.' || nch == '\0') {
+ if (!isalnum(ch))
return (0);
- } else if (periodchar(nch) || nch == '\0') {
- if (!borderchar(ch))
- return (0);
- } else {
- if (!middlechar(ch))
+ } else if (!isalnum(ch) && ch != '-' && ch != '_')
return (0);
+ else if (ch == '_' && warn == 0) {
+ warning("warning: hostname %s contains an "
+ "underscore which violates RFC 952", name);
+ warn++;
}
pch = ch, ch = nch;
}
@@ -2287,7 +2278,7 @@ ipv4addrs(char * buf)
while (inet_aton(buf, &jnk) == 1){
count++;
- while (periodchar(*buf) || digitchar(*buf))
+ while (*buf == '.' || isdigit(*buf))
buf++;
if (*buf == '\0')
return (count);