2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-31 06:15:55 +00:00

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.
This commit is contained in:
Shawn Routhier
2010-09-13 22:06:37 +00:00
parent 83d409ae59
commit 6aaaf6a460
6 changed files with 160 additions and 95 deletions

View File

@@ -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;