--- common/options.c.orig Wed Feb 20 05:36:52 2002 +++ common/options.c Mon Jun 24 10:49:54 2002 @@ -55,6 +55,7 @@ static void do_option_set PROTO ((pair *, struct option_cache *, enum statement_op)); +static void *jmemcpy(void *d_, const void *s_, size_t len); /* Parse all available options out of the specified packet. */ @@ -322,6 +323,8 @@ for (i = 3; i < length && buffer [i] != '.'; i++); i -= 3; + if (i) + jmemcpy(&bp->data[5], &bp->data[5], i); /* Note: If the client sends a FQDN, the first '.' will be used as a NUL terminator for the hostname. */ if (i) @@ -1396,6 +1399,8 @@ op -> option = option; + if (op->option->code == DHO_HOST_NAME) + jmemcpy(buffer, buffer, length); /* Now store the option. */ save_option (universe, options, op); @@ -2228,5 +2233,28 @@ #if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY) dump_rc_history (0); #endif +} + +#define issafe(c) (isalnum(c)||(c)=='-') +static void *jmemcpy(void *d_, const void *s_, size_t len) +{ + /* RFC-1035 */ + unsigned char *d = d_; + const unsigned char *s = s_; + int i; + for (i = 0; i < len; i++) { + if (i == 0) { + *d = isalpha(*s) ? tolower(*s) : 'o'; + } + else if (i == len - 1) { + *d = (isalnum(*s) || *s == '\0') ? tolower(*s) : 'e'; + } + else { + *d = issafe(*s) ? tolower(*s) : '-'; + } + d++; + s++; + } + return d_; }