From: Ted Lemon Date: Wed, 21 Jul 1999 14:30:28 +0000 (+0000) Subject: - Remove NUL from end of host-name option after checking it, so that X-Git-Tag: V3-BETA-1-PATCH-2~5^2~168 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9e0e9ed858ccd22db6921a4f23a262494e4e7d3a;p=thirdparty%2Fdhcp.git - Remove NUL from end of host-name option after checking it, so that host-name can reliably be used in concat expressions. (From Brian Murrell) --- diff --git a/server/dhcp.c b/server/dhcp.c index dfe82bbe2..c4951a2bf 100644 --- a/server/dhcp.c +++ b/server/dhcp.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: dhcp.c,v 1.103 1999/07/19 01:15:22 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dhcp.c,v 1.104 1999/07/21 14:30:28 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -1247,6 +1247,19 @@ void ack_lease (packet, lease, offer, when, msg) lt.subnet = lease -> subnet; lt.billing_class = lease -> billing_class; + /* Set a flag if this client is a broken client that NUL + terminates string options and expects us to do likewise. */ + lease -> flags &= ~MS_NULL_TERMINATION; + if ((oc = lookup_option (&dhcp_universe, packet -> options, + DHO_HOST_NAME))) { + if (!oc -> expression) + if (oc -> data.len && + oc -> data.data [oc -> data.len - 1] == 0) { + lease -> flags |= MS_NULL_TERMINATION; + oc -> data.len--; + } + } + /* Do the DDNS update. It needs to be done here so that the lease structure values for the forward and reverse names are in place for supercede()->write_lease() to be able to write into the dhcpd.leases @@ -1302,19 +1315,6 @@ void ack_lease (packet, lease, offer, when, msg) /* Remember the interface on which the packet arrived. */ state -> ip = packet -> interface; - /* Set a flag if this client is a broken client that NUL - terminates string options and expects us to do likewise. */ - lease -> flags &= ~MS_NULL_TERMINATION; - if ((oc = lookup_option (&dhcp_universe, packet -> options, - DHO_HOST_NAME))) { - if (evaluate_option_cache (&d1, packet, - packet -> options, lease, oc)) { - if (d1.data [d1.len - 1] == '\0') - lease -> flags |= MS_NULL_TERMINATION; - data_string_forget (&d1, "ack_lease"); - } - } - /* Remember the giaddr, xid, secs, flags and hops. */ state -> giaddr = packet -> raw -> giaddr; state -> ciaddr = packet -> raw -> ciaddr;