Date: Fri, 12 Dec 2003 00:40:03 GMT From: Alex <xfb52@dial.pipex.com> To: FreeBSD-gnats-submit@FreeBSD.org Cc: xfb52@dial.pipex.com Subject: ports/60170: x11-clocks/xalarm (3.06) can fail in December Message-ID: <200312120040.hBC0e3wX093553@82-41-35-57.cable.ubr05.edin.blueyonder.co.uk> Resent-Message-ID: <200312120050.hBC0oD1V098306@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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@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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200312120040.hBC0e3wX093553>