Hi Jiri,
Thanks for the patch. Our guys will review and we will get back to you
asap as to if we can include this in an upcoming release or not.
Best Regards,
Larissa
ISC Product Manager
On Sep 3, 2010, at 10:16 AM, Jiri Popelka via RT wrote:
>
> Fri Sep 03 17:16:21 2010: Request 22033 was acted upon.
> Transaction: Ticket created by jpopelka@redhat.com
> Queue: dhcp
> Subject: dhcp-4.2.0 uses int for handling time values
> Owner: Nobody
> Requestors: jpopelka@redhat.com
> Status: new
> Ticket <URL:
https://bugs.isc.org/Ticket/Display.html?id=22033 >
> -----------------------------------------------------------------------
>
> Hello there in ISC,
>
> There can be one small improvement in the newly (dhcp-4.2.0) added
> code.
> In common/dispatch.c the add_timeout() function was slightly modified.
> Problem is that the newly added code uses
> int sec, usec;
> for manipulating with time values, e.g.
> sec = when->tv_sec - cur_tv.tv_sec
>
> This can cause problems on 64bit machines when some crazy server sends
> huge values of lease-time/renewal-time/rebinding-time.
> For real example see
>
https://bugzilla.redhat.com/show_bug.cgi?id=628258
>
> Attached is patch that fixes it.
> Regards
>
> Jiri Popelka
> Red Hat, inc.
>
> diff -up dhcp-4.2.0/common/dispatch.c.time dhcp-4.2.0/common/
> dispatch.c
> --- dhcp-4.2.0/common/dispatch.c.time 2010-06-01 19:29:59.000000000
> +0200
> +++ dhcp-4.2.0/common/dispatch.c 2010-09-03 18:30:08.000000000 +0200
> @@ -185,7 +185,7 @@ void add_timeout (when, where, what, ref
> struct timeout *t, *q;
> int usereset = 0;
> isc_result_t status;
> - int sec, usec;
> + struct timeval relative_time;
> isc_interval_t interval;
> isc_time_t expires;
>
> @@ -293,24 +293,24 @@ void add_timeout (when, where, what, ref
> * about the usec value, if it's zero we assume the caller didn't
> care.
> */
>
> - sec = when->tv_sec - cur_tv.tv_sec;
> - usec = when->tv_usec - cur_tv.tv_usec;
> + relative_time.tv_sec = when->tv_sec - cur_tv.tv_sec;
> + relative_time.tv_usec = when->tv_usec - cur_tv.tv_usec;
>
> - if ((when->tv_usec != 0) && (usec < 0)) {
> - sec--;
> - usec += USEC_MAX;
> + if ((when->tv_usec != 0) && (relative_time.tv_usec < 0)) {
> + relative_time.tv_sec--;
> + relative_time.tv_usec += USEC_MAX;
> }
>
> - if (sec < 0) {
> - sec = 0;
> - usec = 0;
> - } else if (usec < 0) {
> - usec = 0;
> - } else if (usec >= USEC_MAX) {
> - usec = USEC_MAX - 1;
> + if (relative_time.tv_sec < 0) {
> + relative_time.tv_sec = 0;
> + relative_time.tv_usec = 0;
> + } else if (relative_time.tv_usec < 0) {
> + relative_time.tv_usec = 0;
> + } else if (relative_time.tv_usec >= USEC_MAX) {
> + relative_time.tv_usec = USEC_MAX - 1;
> }
>
> - isc_interval_set(&interval, sec, usec * 1000);
> + isc_interval_set(&interval, relative_time.tv_sec,
> relative_time.tv_usec * 1000);
> status = isc_time_nowplusinterval(&expires, &interval);
> if (status != ISC_R_SUCCESS) {
> /*