From: Ted Lemon Date: Thu, 9 Apr 1998 04:31:59 +0000 (+0000) Subject: Allow for null trees. X-Git-Tag: carrel-2~138 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6f76b6ac672958e86489d8b1ecefff5b380b21ef;p=thirdparty%2Fdhcp.git Allow for null trees. --- diff --git a/common/options.c b/common/options.c index 4fb57d46f..8d6d4ed7f 100644 --- a/common/options.c +++ b/common/options.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: options.c,v 1.29 1998/03/17 06:12:17 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: options.c,v 1.30 1998/04/09 04:31:59 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #define DHCP_OPTION_DATA @@ -456,6 +456,10 @@ int store_options (buffer, buflen, options, priority_list, priority_len, continue; } + /* If it evaluated to nothing, don't send the option. */ + if (!options [code] -> len) + continue; + /* We should now have a constant length for the option. */ length = options [code] -> len; diff --git a/common/tree.c b/common/tree.c index ac83d6700..daf710fee 100644 --- a/common/tree.c +++ b/common/tree.c @@ -3,7 +3,7 @@ Routines for manipulating parse trees... */ /* - * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium. + * Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: tree.c,v 1.10 1997/05/09 08:14:57 mellon Exp $ Copyright (c) 1995, 1996, 1997 The Internet Software Consortium. All rights reserved.\n"; +"$Id: tree.c,v 1.11 1998/04/09 04:31:21 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -116,12 +116,17 @@ struct tree *tree_const (data, len) int len; { struct tree *nt; - if (!(nt = new_tree ("tree_const")) - || !(nt -> data.const_val.data = - (unsigned char *)dmalloc (len, "tree_const"))) + if (!(nt = new_tree ("tree_const"))) error ("No memory for constant data tree node."); + if (len) { + if (!(nt -> data.const_val.data = + (unsigned char *)dmalloc (len, "tree_const"))) + error ("No memory for constant data tree data."); + memcpy (nt -> data.const_val.data, data, len); + } else + nt -> data.const_val.data = 0; + nt -> op = TREE_CONST; - memcpy (nt -> data.const_val.data, data, len); nt -> data.const_val.len = len; return nt; } @@ -261,9 +266,10 @@ static TIME tree_evaluate_recurse (bufix, bufp, bufcount, tree) tree -> data.host_lookup.host); case TREE_CONST: - do_data_copy (bufix, bufp, bufcount, - tree -> data.const_val.data, - tree -> data.const_val.len); + if (tree -> data.const_val.data) + do_data_copy (bufix, bufp, bufcount, + tree -> data.const_val.data, + tree -> data.const_val.len); t1 = MAX_TIME; return t1;