From: Damien Neil Date: Mon, 14 Aug 2000 21:58:04 +0000 (+0000) Subject: Fix assorted code which assumes that leases will always have an X-Git-Tag: V3-BETA-2-PATCH-1~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4244dfb75f9e5c644765580a992d9c03a99f3e92;p=thirdparty%2Fdhcp.git Fix assorted code which assumes that leases will always have an associated hardware address. --- diff --git a/server/omapi.c b/server/omapi.c index 9711bdc73..faf3b3567 100644 --- a/server/omapi.c +++ b/server/omapi.c @@ -50,7 +50,7 @@ #ifndef lint static char copyright[] = -"$Id: omapi.c,v 1.33 2000/07/06 22:37:53 mellon Exp $ Copyright (c) 1999-2000 The Internet Software Consortium. All rights reserved.\n"; +"$Id: omapi.c,v 1.34 2000/08/14 21:58:04 neild Exp $ Copyright (c) 1999-2000 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -284,14 +284,20 @@ isc_result_t dhcp_lease_get_value (omapi_object_t *h, omapi_object_t *id, ((omapi_object_t *)lease -> billing_class), MDL); return ISC_R_NOTFOUND; - } else if (!omapi_ds_strcmp (name, "hardware-address")) - return omapi_make_const_value - (value, name, &lease -> hardware_addr.hbuf [1], - (unsigned)(lease -> hardware_addr.hlen - 1), MDL); - else if (!omapi_ds_strcmp (name, "hardware-type")) - return omapi_make_int_value (value, name, - lease -> hardware_addr.hbuf [0], - MDL); + } else if (!omapi_ds_strcmp (name, "hardware-address")) { + if (lease -> hardware_addr.hlen) + return omapi_make_const_value + (value, name, &lease -> hardware_addr.hbuf [1], + (unsigned)(lease -> hardware_addr.hlen - 1), + MDL); + return ISC_R_NOTFOUND; + } else if (!omapi_ds_strcmp (name, "hardware-type")) { + if (lease -> hardware_addr.hlen) + return omapi_make_int_value + (value, name, lease -> hardware_addr.hbuf [0], + MDL); + return ISC_R_NOTFOUND; + } /* Try to find some inner object that can take the value. */ if (h -> inner && h -> inner -> type -> get_value) { @@ -485,30 +491,33 @@ isc_result_t dhcp_lease_stuff_values (omapi_object_t *c, if (status != ISC_R_SUCCESS) return status; - status = omapi_connection_put_name (c, "hardware-address"); - if (status != ISC_R_SUCCESS) - return status; - status = (omapi_connection_put_uint32 - (c, (unsigned long)(lease -> hardware_addr.hlen - 1))); - if (status != ISC_R_SUCCESS) - return status; - status = (omapi_connection_copyin - (c, &lease -> hardware_addr.hbuf [1], - (unsigned long)(lease -> hardware_addr.hlen - 1))); - - if (status != ISC_R_SUCCESS) - return status; + if (lease -> hardware_addr.hlen) { + status = omapi_connection_put_name (c, "hardware-address"); + if (status != ISC_R_SUCCESS) + return status; + status = (omapi_connection_put_uint32 + (c, + (unsigned long)(lease -> hardware_addr.hlen - 1))); + if (status != ISC_R_SUCCESS) + return status; + status = (omapi_connection_copyin + (c, &lease -> hardware_addr.hbuf [1], + (unsigned long)(lease -> hardware_addr.hlen - 1))); - status = omapi_connection_put_name (c, "hardware-type"); - if (status != ISC_R_SUCCESS) - return status; - status = omapi_connection_put_uint32 (c, sizeof (int)); - if (status != ISC_R_SUCCESS) - return status; - status = omapi_connection_put_uint32 (c, - lease -> hardware_addr.hbuf [0]); - if (status != ISC_R_SUCCESS) - return status; + if (status != ISC_R_SUCCESS) + return status; + + status = omapi_connection_put_name (c, "hardware-type"); + if (status != ISC_R_SUCCESS) + return status; + status = omapi_connection_put_uint32 (c, sizeof (int)); + if (status != ISC_R_SUCCESS) + return status; + status = omapi_connection_put_uint32 + (c, lease -> hardware_addr.hbuf [0]); + if (status != ISC_R_SUCCESS) + return status; + } status = omapi_connection_put_name (c, "ends");