ports/60170: x11-clocks/xalarm (3.06) can fail in December

Alex xfb52 at dial.pipex.com
Fri Dec 12 00:50:16 UTC 2003


>Number:         60170
>Category:       ports
>Synopsis:       x11-clocks/xalarm (3.06) can fail in December
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 11 16:50:12 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Alex
>Release:        FreeBSD 4.8-RELEASE-p14 i386
>Organization:
>Environment:
System: FreeBSD cartman 4.8-RELEASE-p14 FreeBSD 4.8-RELEASE-p14 #1: Sat Dec 6 10:11:32 GMT 2003 alex at cartman:/usr/src/sys/compile/CARTMAN i386


	
>Description:

NB priority marked high because bug becomes problematic to trigger in
any month other than December!

There's a bug in xalarm-3.06.  In December only, alarms which are set
to trigger on a particular day of any month (e.g. the 1st) will send
xalarm into an infinite loop if that date in December has passed.
E.g. on the 2nd Dec any alarm set to trigger on the first of any month
will cause an infinite loop.

The bug happens because the code trying to find how long it is before
each alarm is due only ever increments the month (modulo 12) and
forgets to ever increment the year.  Hence in December, it tries Dec
of the current year then Jan of the current year then Feb of the
current year etc. when it should try Dec of the current year, Jan of
the next year ...

Attached is a patch which fixes the problem for me.

>How-To-Repeat:

Create an xalarm file (~/.xalarms is the default) with

1 - Alarm

Run 
        xalarm -file today

xalarm goes into infinite loop if the current date is in December and after the 1st.

>Fix:

Apply supplied patch or avoid dates which do not specify a month.

--- patch-dates begins here ---
--- dates.c	Wed Jul 12 16:24:26 1995
+++ /home/alex/scratch/xalarm/dates.c	Thu Dec  4 00:36:27 2003
@@ -296,11 +296,16 @@
 	if (month >= 0)			date->tm_mon = month;
 	if (year >= 0)			date->tm_year = year;
 	while ((year < 0) and (date->tm_year < (2500-1900)) and
-	       (DaysBetween (&today, date) < 0))
-	    if (month < 0)
-		date->tm_mon = (date->tm_mon + 1) % 12;
-	    else
+	       (DaysBetween (&today, date) < 0)) {
+	    if (month < 0) {
+	      date->tm_mon++;
+		if (date->tm_mon > 11) {
+		    date->tm_mon = 0;
+		    date->tm_year++;
+		}
+	    } else
 		date->tm_year++;
+	}
     } else
 	/* 
 	 * We assume Buck Rodgers will have something better than xalarm...
--- patch-dates ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list