208 lines
6.3 KiB
Diff
208 lines
6.3 KiB
Diff
diff -up dhcp-4.2.0/common/parse.c.parse_date dhcp-4.2.0/common/parse.c
|
|
--- dhcp-4.2.0/common/parse.c.parse_date 2010-07-21 16:11:36.000000000 +0200
|
|
+++ dhcp-4.2.0/common/parse.c 2010-07-21 16:23:10.000000000 +0200
|
|
@@ -913,48 +913,46 @@ parse_date_core(cfile)
|
|
212, 243, 273, 304, 334 };
|
|
|
|
/* Day of week, or "never"... */
|
|
- token = next_token (&val, (unsigned *)0, cfile);
|
|
+ token = peek_token (&val, (unsigned *)0, cfile);
|
|
if (token == NEVER) {
|
|
- if (!parse_semi (cfile))
|
|
- return 0;
|
|
+ next_token (&val, (unsigned *)0, cfile); /* consume NEVER*/
|
|
return MAX_TIME;
|
|
}
|
|
|
|
/* This indicates 'local' time format. */
|
|
if (token == EPOCH) {
|
|
- token = next_token(&val, NULL, cfile);
|
|
-
|
|
+ next_token(&val, (unsigned *)0, cfile); /* consume EPOCH */
|
|
+ token = peek_token (&val, (unsigned *)0, cfile);
|
|
if (token != NUMBER) {
|
|
parse_warn(cfile, "Seconds since epoch expected.");
|
|
if (token != SEMI)
|
|
- skip_to_semi(cfile);
|
|
+ next_token(&val, (unsigned *)0, cfile);
|
|
return (TIME)0;
|
|
}
|
|
+ next_token(&val, (unsigned *)0, cfile); /* consume seconds */
|
|
|
|
guess = atol(val);
|
|
-
|
|
- if (!parse_semi(cfile))
|
|
- return (TIME)0;
|
|
-
|
|
return guess;
|
|
}
|
|
|
|
if (token != NUMBER) {
|
|
parse_warn (cfile, "numeric day of week expected.");
|
|
if (token != SEMI)
|
|
- skip_to_semi (cfile);
|
|
+ next_token(&val, (unsigned *)0, cfile);
|
|
return (TIME)0;
|
|
}
|
|
+ next_token(&val, (unsigned *)0, cfile); /* consume day of week */
|
|
wday = atol (val);
|
|
|
|
/* Year... */
|
|
- token = next_token (&val, (unsigned *)0, cfile);
|
|
+ token = peek_token (&val, (unsigned *)0, cfile);
|
|
if (token != NUMBER) {
|
|
parse_warn (cfile, "numeric year expected.");
|
|
if (token != SEMI)
|
|
- skip_to_semi (cfile);
|
|
+ next_token(&val, (unsigned *)0, cfile);
|
|
return (TIME)0;
|
|
}
|
|
+ next_token(&val, (unsigned *)0, cfile); /* consume Year*/
|
|
|
|
/* Note: the following is not a Y2K bug - it's a Y1.9K bug. Until
|
|
somebody invents a time machine, I think we can safely disregard
|
|
@@ -965,101 +963,113 @@ parse_date_core(cfile)
|
|
year -= 1900;
|
|
|
|
/* Slash separating year from month... */
|
|
- token = next_token (&val, (unsigned *)0, cfile);
|
|
+ token = peek_token (&val, (unsigned *)0, cfile);
|
|
if (token != SLASH) {
|
|
parse_warn (cfile,
|
|
"expected slash separating year from month.");
|
|
if (token != SEMI)
|
|
- skip_to_semi (cfile);
|
|
+ next_token(&val, (unsigned *)0, cfile);
|
|
return (TIME)0;
|
|
}
|
|
+ token = next_token(&val, (unsigned *)0, cfile); /* consume SLASH */
|
|
|
|
/* Month... */
|
|
- token = next_token (&val, (unsigned *)0, cfile);
|
|
+ token = peek_token (&val, (unsigned *)0, cfile);
|
|
if (token != NUMBER) {
|
|
parse_warn (cfile, "numeric month expected.");
|
|
if (token != SEMI)
|
|
- skip_to_semi (cfile);
|
|
+ next_token(&val, (unsigned *)0, cfile);
|
|
return (TIME)0;
|
|
}
|
|
+ next_token(&val, (unsigned *)0, cfile); /* consume Month */
|
|
mon = atol (val) - 1;
|
|
|
|
/* Slash separating month from day... */
|
|
- token = next_token (&val, (unsigned *)0, cfile);
|
|
+ token = peek_token (&val, (unsigned *)0, cfile);
|
|
if (token != SLASH) {
|
|
parse_warn (cfile,
|
|
"expected slash separating month from day.");
|
|
if (token != SEMI)
|
|
- skip_to_semi (cfile);
|
|
+ next_token(&val, (unsigned *)0, cfile);
|
|
return (TIME)0;
|
|
}
|
|
+ next_token(&val, (unsigned *)0, cfile); /* consume SLASH */
|
|
|
|
/* Day of month... */
|
|
- token = next_token (&val, (unsigned *)0, cfile);
|
|
+ token = peek_token (&val, (unsigned *)0, cfile);
|
|
if (token != NUMBER) {
|
|
parse_warn (cfile, "numeric day of month expected.");
|
|
if (token != SEMI)
|
|
- skip_to_semi (cfile);
|
|
+ next_token(&val, (unsigned *)0, cfile);
|
|
return (TIME)0;
|
|
}
|
|
+ next_token(&val, (unsigned *)0, cfile); /* consume Day of month */
|
|
mday = atol (val);
|
|
|
|
/* Hour... */
|
|
- token = next_token (&val, (unsigned *)0, cfile);
|
|
+ token = peek_token (&val, (unsigned *)0, cfile);
|
|
if (token != NUMBER) {
|
|
parse_warn (cfile, "numeric hour expected.");
|
|
if (token != SEMI)
|
|
- skip_to_semi (cfile);
|
|
+ next_token(&val, (unsigned *)0, cfile);
|
|
return (TIME)0;
|
|
}
|
|
+ next_token(&val, (unsigned *)0, cfile); /* consume Hour */
|
|
hour = atol (val);
|
|
|
|
/* Colon separating hour from minute... */
|
|
- token = next_token (&val, (unsigned *)0, cfile);
|
|
+ token = peek_token (&val, (unsigned *)0, cfile);
|
|
if (token != COLON) {
|
|
parse_warn (cfile,
|
|
"expected colon separating hour from minute.");
|
|
if (token != SEMI)
|
|
- skip_to_semi (cfile);
|
|
+ next_token(&val, (unsigned *)0, cfile);
|
|
return (TIME)0;
|
|
}
|
|
+ next_token(&val, (unsigned *)0, cfile); /* consume Colon */
|
|
|
|
/* Minute... */
|
|
- token = next_token (&val, (unsigned *)0, cfile);
|
|
+ token = peek_token (&val, (unsigned *)0, cfile);
|
|
if (token != NUMBER) {
|
|
parse_warn (cfile, "numeric minute expected.");
|
|
if (token != SEMI)
|
|
- skip_to_semi (cfile);
|
|
+ next_token(&val, (unsigned *)0, cfile);
|
|
return (TIME)0;
|
|
}
|
|
+ next_token(&val, (unsigned *)0, cfile); /* consume Minute */
|
|
min = atol (val);
|
|
|
|
/* Colon separating minute from second... */
|
|
- token = next_token (&val, (unsigned *)0, cfile);
|
|
+ token = peek_token (&val, (unsigned *)0, cfile);
|
|
if (token != COLON) {
|
|
parse_warn (cfile,
|
|
"expected colon separating minute from second.");
|
|
if (token != SEMI)
|
|
- skip_to_semi (cfile);
|
|
+ next_token(&val, (unsigned *)0, cfile);
|
|
return (TIME)0;
|
|
}
|
|
+ next_token(&val, (unsigned *)0, cfile); /* consume Colon */
|
|
|
|
/* Second... */
|
|
- token = next_token (&val, (unsigned *)0, cfile);
|
|
+ token = peek_token (&val, (unsigned *)0, cfile);
|
|
if (token != NUMBER) {
|
|
parse_warn (cfile, "numeric second expected.");
|
|
if (token != SEMI)
|
|
- skip_to_semi (cfile);
|
|
+ next_token(&val, (unsigned *)0, cfile);
|
|
return (TIME)0;
|
|
}
|
|
+ next_token(&val, (unsigned *)0, cfile); /* consume Second */
|
|
sec = atol (val);
|
|
|
|
+ tzoff = 0;
|
|
token = peek_token (&val, (unsigned *)0, cfile);
|
|
if (token == NUMBER) {
|
|
- token = next_token (&val, (unsigned *)0, cfile);
|
|
+ next_token (&val, (unsigned *)0, cfile); /* consume tzoff */
|
|
tzoff = atol (val);
|
|
- } else
|
|
- tzoff = 0;
|
|
+ } else if (token != SEMI) {
|
|
+ parse_warn (cfile, "Time zone offset or semicolon expected.");
|
|
+ next_token (&val, (unsigned *)0, cfile);
|
|
+ }
|
|
|
|
/* Guess the time value... */
|
|
guess = ((((((365 * (year - 70) + /* Days in years since '70 */
|
|
@@ -1095,7 +1105,7 @@ parse_date(cfile)
|
|
|
|
/* Make sure the date ends in a semicolon... */
|
|
if (!parse_semi(cfile))
|
|
- return 0;
|
|
+ return (TIME)0;
|
|
return guess;
|
|
}
|
|
|