From 63aa3f4bc64629624c2507f10b82a9cfe8ff29ca Mon Sep 17 00:00:00 2001 From: Jiri Popelka Date: Sep 01 2010 11:22:34 +0000 Subject: Fix parsing of lease file dates & times on 64-bit platforms (#628258) --- diff --git a/dhcp-4.2.0-64_bit_lease_parse.patch b/dhcp-4.2.0-64_bit_lease_parse.patch index 4e87c56..0d3ff65 100644 --- a/dhcp-4.2.0-64_bit_lease_parse.patch +++ b/dhcp-4.2.0-64_bit_lease_parse.patch @@ -1,6 +1,6 @@ diff -up dhcp-4.2.0/common/parse.c.64-bit_lease_parse dhcp-4.2.0/common/parse.c --- dhcp-4.2.0/common/parse.c.64-bit_lease_parse 2009-10-28 05:12:29.000000000 +0100 -+++ dhcp-4.2.0/common/parse.c 2010-07-21 16:11:36.000000000 +0200 ++++ dhcp-4.2.0/common/parse.c 2010-09-01 13:06:31.000000000 +0200 @@ -905,8 +905,8 @@ TIME parse_date_core(cfile) struct parse *cfile; @@ -12,3 +12,90 @@ diff -up dhcp-4.2.0/common/parse.c.64-bit_lease_parse dhcp-4.2.0/common/parse.c const char *val; enum dhcp_token token; static int months [11] = { 31, 59, 90, 120, 151, 181, +@@ -931,7 +931,7 @@ parse_date_core(cfile) + return (TIME)0; + } + +- guess = atoi(val); ++ guess = atol(val); + + if (!parse_semi(cfile)) + return (TIME)0; +@@ -945,7 +945,7 @@ parse_date_core(cfile) + skip_to_semi (cfile); + return (TIME)0; + } +- wday = atoi (val); ++ wday = atol (val); + + /* Year... */ + token = next_token (&val, (unsigned *)0, cfile); +@@ -960,7 +960,7 @@ parse_date_core(cfile) + somebody invents a time machine, I think we can safely disregard + it. This actually works around a stupid Y2K bug that was present + in a very early beta release of dhcpd. */ +- year = atoi (val); ++ year = atol (val); + if (year > 1900) + year -= 1900; + +@@ -982,7 +982,7 @@ parse_date_core(cfile) + skip_to_semi (cfile); + return (TIME)0; + } +- mon = atoi (val) - 1; ++ mon = atol (val) - 1; + + /* Slash separating month from day... */ + token = next_token (&val, (unsigned *)0, cfile); +@@ -1002,7 +1002,7 @@ parse_date_core(cfile) + skip_to_semi (cfile); + return (TIME)0; + } +- mday = atoi (val); ++ mday = atol (val); + + /* Hour... */ + token = next_token (&val, (unsigned *)0, cfile); +@@ -1012,7 +1012,7 @@ parse_date_core(cfile) + skip_to_semi (cfile); + return (TIME)0; + } +- hour = atoi (val); ++ hour = atol (val); + + /* Colon separating hour from minute... */ + token = next_token (&val, (unsigned *)0, cfile); +@@ -1032,7 +1032,7 @@ parse_date_core(cfile) + skip_to_semi (cfile); + return (TIME)0; + } +- min = atoi (val); ++ min = atol (val); + + /* Colon separating minute from second... */ + token = next_token (&val, (unsigned *)0, cfile); +@@ -1052,12 +1052,12 @@ parse_date_core(cfile) + skip_to_semi (cfile); + return (TIME)0; + } +- sec = atoi (val); ++ sec = atol (val); + + token = peek_token (&val, (unsigned *)0, cfile); + if (token == NUMBER) { + token = next_token (&val, (unsigned *)0, cfile); +- tzoff = atoi (val); ++ tzoff = atol (val); + } else + tzoff = 0; + +@@ -1090,7 +1090,7 @@ TIME + parse_date(cfile) + struct parse *cfile; + { +- int guess; ++ TIME guess; + guess = parse_date_core(cfile); + + /* Make sure the date ends in a semicolon... */ diff --git a/dhcp-4.2.0-parse_date.patch b/dhcp-4.2.0-parse_date.patch index c72d8b6..1eebcc9 100644 --- a/dhcp-4.2.0-parse_date.patch +++ b/dhcp-4.2.0-parse_date.patch @@ -29,7 +29,7 @@ diff -up dhcp-4.2.0/common/parse.c.parse_date dhcp-4.2.0/common/parse.c } + next_token(&val, (unsigned *)0, cfile); /* consume seconds */ - guess = atoi(val); + guess = atol(val); - - if (!parse_semi(cfile)) - return (TIME)0; @@ -45,7 +45,7 @@ diff -up dhcp-4.2.0/common/parse.c.parse_date dhcp-4.2.0/common/parse.c return (TIME)0; } + next_token(&val, (unsigned *)0, cfile); /* consume day of week */ - wday = atoi (val); + wday = atol (val); /* Year... */ - token = next_token (&val, (unsigned *)0, cfile); @@ -88,7 +88,7 @@ diff -up dhcp-4.2.0/common/parse.c.parse_date dhcp-4.2.0/common/parse.c return (TIME)0; } + next_token(&val, (unsigned *)0, cfile); /* consume Month */ - mon = atoi (val) - 1; + mon = atol (val) - 1; /* Slash separating month from day... */ - token = next_token (&val, (unsigned *)0, cfile); @@ -114,7 +114,7 @@ diff -up dhcp-4.2.0/common/parse.c.parse_date dhcp-4.2.0/common/parse.c return (TIME)0; } + next_token(&val, (unsigned *)0, cfile); /* consume Day of month */ - mday = atoi (val); + mday = atol (val); /* Hour... */ - token = next_token (&val, (unsigned *)0, cfile); @@ -127,7 +127,7 @@ diff -up dhcp-4.2.0/common/parse.c.parse_date dhcp-4.2.0/common/parse.c return (TIME)0; } + next_token(&val, (unsigned *)0, cfile); /* consume Hour */ - hour = atoi (val); + hour = atol (val); /* Colon separating hour from minute... */ - token = next_token (&val, (unsigned *)0, cfile); @@ -153,7 +153,7 @@ diff -up dhcp-4.2.0/common/parse.c.parse_date dhcp-4.2.0/common/parse.c return (TIME)0; } + next_token(&val, (unsigned *)0, cfile); /* consume Minute */ - min = atoi (val); + min = atol (val); /* Colon separating minute from second... */ - token = next_token (&val, (unsigned *)0, cfile); @@ -179,14 +179,14 @@ diff -up dhcp-4.2.0/common/parse.c.parse_date dhcp-4.2.0/common/parse.c return (TIME)0; } + next_token(&val, (unsigned *)0, cfile); /* consume Second */ - sec = atoi (val); + 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 = atoi (val); + tzoff = atol (val); - } else - tzoff = 0; + } else if (token != SEMI) { diff --git a/dhcp.spec b/dhcp.spec index 44f5331..a4d2323 100644 --- a/dhcp.spec +++ b/dhcp.spec @@ -7,7 +7,7 @@ Summary: Dynamic host configuration protocol software Name: dhcp Version: 4.2.0 -Release: 4%{?dist} +Release: 5%{?dist} # NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to # dcantrell maintaining the package) made incorrect use of the epoch and # that's why it is at 12 now. It should have never been used, but it was. @@ -510,6 +510,9 @@ fi %attr(0644,root,root) %{_mandir}/man3/omapi.3.gz %changelog +* Tue Sep 1 2010 Jiri Popelka - 12:4.2.0-5 +- Fix parsing of lease file dates & times on 64-bit platforms (#628258) + * Tue Aug 31 2010 Jiri Popelka - 12:4.2.0-4 - RFC 3442 - Classless Static Route Option for DHCPv4 (#516325)