[Nagios-devel] Fix for mktime() issue

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] Fix for mktime() issue

Post by Guest »

--=-ZuWqGl0DFQFWR8Afdl1W
Content-Type: multipart/mixed; boundary="=-Duegzwr8RzeFLgERV/JS"

--=-Duegzwr8RzeFLgERV/JS
Content-Type: text/plain; charset=us-ascii; DelSp=Yes; Format=Flowed
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi all:

please find attached to this message a diff against the current cvs =20
which fixes a strange issue in Nagios 3.0.6 I discovered a while ago =20
[1, 2]. Using it on my Ubuntu Hardy server since then, it seems to =20
properly fix the issue. As always, any comment is welcome!

All the best for a happy, healthy and prosperous new year 2009,
Cheers,
Albrecht.

[1]
[2]

--=-Duegzwr8RzeFLgERV/JS
Content-Type: text/x-patch; charset=us-ascii; name=mktime-bug.diff
Content-Disposition: attachment; filename=mktime-bug.diff
Content-Transfer-Encoding: quoted-printable

? mktime-bug.diff
? html/config.inc.php
Index: base/utils.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/nagios/nagios/base/utils.c,v
retrieving revision 1.235
diff -u -r1.235 utils.c
--- base/utils.c 14 Dec 2008 14:52:23 -0000 1.235
+++ base/utils.c 30 Dec 2008 17:30:14 -0000
@@ -837,6 +837,7 @@
t->tm_sec=3D0;
t->tm_min=3D0;
t->tm_hour=3D0;
+ t->tm_isdst=3D-1;
midnight=3D(unsigned long)mktime(t);
=20
/**** check exceptions first ****/
@@ -860,6 +861,7 @@
t->tm_mday=3Dtemp_daterange->smday;
t->tm_mon=3Dtemp_daterange->smon;
t->tm_year=3D(temp_daterange->syear-1900);
+ t->tm_isdst=3D-1;
start_time=3Dmktime(t);
break;
case DATERANGE_MONTH_DATE:
@@ -889,6 +891,7 @@
t->tm_mday=3Dtemp_daterange->emday;
t->tm_mon=3Dtemp_daterange->emon;
t->tm_year=3D(temp_daterange->eyear-1900);
+ t->tm_isdst=3D-1;
end_time=3Dmktime(t);
break;
case DATERANGE_MONTH_DATE:
@@ -1124,6 +1127,7 @@
t->tm_sec=3D0;
t->tm_min=3D0;
t->tm_hour=3D0;
+ t->tm_isdst=3D-1;
midnight=3D(unsigned long)mktime(t);
=20
/* save pref time values for later */
@@ -1164,6 +1168,7 @@
t->tm_mday=3Dtemp_daterange->smday;
t->tm_mon=3Dtemp_daterange->smon;
t->tm_year=3D(temp_daterange->syear-1900);
+ t->tm_isdst=3D-1;
start_time=3Dmktime(t);
break;
case DATERANGE_MONTH_DATE:
@@ -1232,6 +1237,7 @@
t->tm_mday=3Dtemp_daterange->emday;
t->tm_mon=3Dtemp_daterange->emon;
t->tm_year=3D(temp_daterange->eyear-1900);
+ t->tm_isdst=3D-1;
end_time=3Dmktime(t);
break;
case DATERANGE_MONTH_DATE:
@@ -1507,6 +1513,7 @@
t.tm_year=3Dyear;
t.tm_mon=3Dmonth;
t.tm_mday=3Dmonthday;
+ t.tm_isdst=3D-1;
=20
midnight=3Dmktime(&t);
=20
@@ -1532,6 +1539,7 @@
t.tm_mon=3Dmonth;
t.tm_year=3Dyear;
t.tm_mday=3Dday;
+ t.tm_isdst=3D-1;
midnight=3Dmktime(&t);
=20
}while(t.tm_mon!=3Dmonth);
@@ -1542,6 +1550,7 @@
t.tm_year=3Dyear;
/* -1 means last day of month, so add one to to make this correct - Mike=
Bird */
t.tm_mday+=3D(monthday<-30)?-30:monthday+1;
+ t.tm_isdst=3D-1;
midnight=3Dmktime(&t);
=20
/* if we rolled over to the previous month, time is invalid */
@@ -1568,6 +1577,7 @@
t.tm_year=3Dyear;
t.tm_mon=3Dmonth;
t.tm_mday=3D1;
+ t.tm_isdst=3D-1;
=20
midnight=3Dmktime(&t);
=20
@@ -1587,6 +1597,7 @@
t.tm_mon=3Dmonth;
t.tm_year=3Dyear;
t.tm_mday=3Ddays+1;
+ t.tm_isdst=3D-1;
midnight=3Dmktime(&t);
=20
/* if we rolled over to the next month, time is invalid */
@@ -1607,6 +1618,7 @@
t.tm_mon=3Dmonth;
t.tm_year=3Dyear;
t.tm_mday=3Ddays+1;
+ t.tm_isdst=3D-1;
midnight=3Dmktime(&t);
=20
}while(t.tm_mon!=3Dmonth);
@@ -1619,6 +1631,7 @@
t.tm_mon=3Dmonth;
t.tm_year=3Dyear;
t.tm_mday+=3Ddays;
+ t.tm_isdst=3D-1;
midnight=3Dmktime(&t);
=20
/* if we rolled over to the previous month, time is invalid */
Index: cgi/avail.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked