summaryrefslogtreecommitdiff
path: root/client/clparse.c
diff options
context:
space:
mode:
authorShawn Routhier <sar@isc.org>2010-09-13 22:06:37 +0000
committerShawn Routhier <sar@isc.org>2010-09-13 22:06:37 +0000
commit6aaaf6a460725c9fb22f0f2cb782b70a9d9dfcc2 (patch)
tree28bbbb49198842add33bc86f21cec99b3372b198 /client/clparse.c
parent83d409ae5974c45941eb538314131e243a6d4fcc (diff)
downloadisc-dhcp-6aaaf6a460725c9fb22f0f2cb782b70a9d9dfcc2.tar.gz
Fixes to lease input and output.
[ISC-Bugs #20418] - Some systems don't support the "%s" argument to strftime, paste together the same string using mktime instead. [ISC-Bugs #19596] - When parsing iaid values accept printable characters. [ISC-Bugs #21585] - Always print time values in omshell as hex instead of ascii if the values happen to be printable characters.
Diffstat (limited to 'client/clparse.c')
-rw-r--r--client/clparse.c65
1 files changed, 19 insertions, 46 deletions
diff --git a/client/clparse.c b/client/clparse.c
index 6eb6cdee..c4245ce7 100644
--- a/client/clparse.c
+++ b/client/clparse.c
@@ -3,7 +3,7 @@
Parser for dhclient config and lease files... */
/*
- * Copyright (c) 2004-2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -1521,12 +1521,12 @@ parse_client6_lease_statement(struct parse *cfile)
static struct dhc6_ia *
parse_client6_ia_na_statement(struct parse *cfile)
{
- struct data_string id;
struct option_cache *oc = NULL;
struct dhc6_ia *ia;
struct dhc6_addr **addr;
const char *val;
- int token, no_semi;
+ int token, no_semi, len;
+ u_int8_t buf[5];
ia = dmalloc(sizeof(*ia), MDL);
if (ia == NULL) {
@@ -1537,20 +1537,11 @@ parse_client6_ia_na_statement(struct parse *cfile)
ia->ia_type = D6O_IA_NA;
/* Get IAID. */
- memset(&id, 0, sizeof(id));
- if (parse_cshl(&id, cfile)) {
- if (id.len == 4)
- memcpy(ia->iaid, id.data, 4);
- else {
- parse_warn(cfile, "Expecting IAID of length 4, got %d.",
- id.len);
- skip_to_semi(cfile);
- dfree(ia, MDL);
- return NULL;
- }
- data_string_forget(&id, MDL);
+ len = parse_X(cfile, buf, 5);
+ if (len == 4) {
+ memcpy(ia->iaid, buf, 4);
} else {
- parse_warn(cfile, "Expecting IAID.");
+ parse_warn(cfile, "Expecting IAID of length 4, got %d.", len);
skip_to_semi(cfile);
dfree(ia, MDL);
return NULL;
@@ -1658,12 +1649,12 @@ parse_client6_ia_na_statement(struct parse *cfile)
static struct dhc6_ia *
parse_client6_ia_ta_statement(struct parse *cfile)
{
- struct data_string id;
struct option_cache *oc = NULL;
struct dhc6_ia *ia;
struct dhc6_addr **addr;
const char *val;
- int token, no_semi;
+ int token, no_semi, len;
+ u_int8_t buf[5];
ia = dmalloc(sizeof(*ia), MDL);
if (ia == NULL) {
@@ -1674,20 +1665,11 @@ parse_client6_ia_ta_statement(struct parse *cfile)
ia->ia_type = D6O_IA_TA;
/* Get IAID. */
- memset(&id, 0, sizeof(id));
- if (parse_cshl(&id, cfile)) {
- if (id.len == 4)
- memcpy(ia->iaid, id.data, 4);
- else {
- parse_warn(cfile, "Expecting IAID of length 4, got %d.",
- id.len);
- skip_to_semi(cfile);
- dfree(ia, MDL);
- return NULL;
- }
- data_string_forget(&id, MDL);
+ len = parse_X(cfile, buf, 5);
+ if (len == 4) {
+ memcpy(ia->iaid, buf, 4);
} else {
- parse_warn(cfile, "Expecting IAID.");
+ parse_warn(cfile, "Expecting IAID of length 4, got %d.", len);
skip_to_semi(cfile);
dfree(ia, MDL);
return NULL;
@@ -1775,12 +1757,12 @@ parse_client6_ia_ta_statement(struct parse *cfile)
static struct dhc6_ia *
parse_client6_ia_pd_statement(struct parse *cfile)
{
- struct data_string id;
struct option_cache *oc = NULL;
struct dhc6_ia *ia;
struct dhc6_addr **pref;
const char *val;
- int token, no_semi;
+ int token, no_semi, len;
+ u_int8_t buf[5];
ia = dmalloc(sizeof(*ia), MDL);
if (ia == NULL) {
@@ -1791,20 +1773,11 @@ parse_client6_ia_pd_statement(struct parse *cfile)
ia->ia_type = D6O_IA_PD;
/* Get IAID. */
- memset(&id, 0, sizeof(id));
- if (parse_cshl(&id, cfile)) {
- if (id.len == 4)
- memcpy(ia->iaid, id.data, 4);
- else {
- parse_warn(cfile, "Expecting IAID of length 4, got %d.",
- id.len);
- skip_to_semi(cfile);
- dfree(ia, MDL);
- return NULL;
- }
- data_string_forget(&id, MDL);
+ len = parse_X(cfile, buf, 5);
+ if (len == 4) {
+ memcpy(ia->iaid, buf, 4);
} else {
- parse_warn(cfile, "Expecting IAID.");
+ parse_warn(cfile, "Expecting IAID of length 4, got %d.", len);
skip_to_semi(cfile);
dfree(ia, MDL);
return NULL;