Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:GA
dhcp.1901
0035-dhcp-4.x.x-fixed-improper-lease-duration-c...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0035-dhcp-4.x.x-fixed-improper-lease-duration-checking.patch of Package dhcp.1901
From: Marius Tomaschewski <mt@suse.de> Date: Tue, 12 Jan 2016 15:42:22 +0100 Subject: [PATCH] fixed improper lease duration checking. References: bsc#936923, bsc#880984 year 2038 is EOT only for 32 bit machine. This patch checks wordsize and do a proper EOT checking on lease duration. It also fixes integer overflows in the date and time handling code. diff --git a/common/parse.c b/common/parse.c index fa35761..671050e 100644 --- a/common/parse.c +++ b/common/parse.c @@ -932,7 +932,7 @@ TIME parse_date_core(cfile) struct parse *cfile; { - int guess; + long guess; int tzoff, year, mon, mday, hour, min, sec; const char *val; enum dhcp_token token; @@ -959,7 +959,7 @@ parse_date_core(cfile) } skip_token(&val, NULL, cfile); /* consume number */ - guess = atoi(val); + guess = atol(val); return((TIME)guess); } @@ -1101,9 +1101,22 @@ parse_date_core(cfile) "Time zone offset or semicolon expected."); return((TIME)0); } - + if (sizeof(time_t) == 8) { + /* 2038 is not an issue on 64bit. time calculations + * start to fail at almost INT_MAX (- some guard) */ + if (year > 0x7fff0000) + return(MAX_TIME); + } else { + /* assume 32bit with end in 2038 */ + if (year >= 138) + return(MAX_TIME); + } + /* I don't think we need to care about lease starts before 1900 */ + if (year < 0) + return((TIME)0); + /* Guess the time value... */ - guess = ((((((365 * (year - 70) + /* Days in years since '70 */ + guess = ((((((365 * ((long)year - 70) + /* Days in years since '70 */ (year - 69) / 4 + /* Leap days since '70 */ (mon /* Days in months this year */ ? months [mon - 1] diff --git a/includes/dhcpd.h b/includes/dhcpd.h index 55e9dbd..dadff46 100644 --- a/includes/dhcpd.h +++ b/includes/dhcpd.h @@ -1457,7 +1457,7 @@ typedef unsigned char option_mask [16]; #define DHCPD_LOG_FACILITY LOG_DAEMON #endif -#define MAX_TIME 0x7fffffff +#define MAX_TIME LONG_MAX #define MIN_TIME 0 /* these are referenced */
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor