NetBSD Problem Report #1018
From gnats Thu May 4 09:01:34 1995
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.cs.berkeley.edu (8.6.10/8.6.10) with ESMTP id JAA01927 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Thu, 4 May 1995 09:01:31 -0700
Message-Id: <199505041602.CAA19595@scrooge.ee.swin.oz.au>
Date: Fri, 5 May 1995 02:02:13 +1000 (EST)
From: Douglas Thomas Crosher <dtc@scrooge.ee.swin.oz.au>
To: gnats-bugs@NetBSD.ORG
Subject: calendar does not check for end of strings when interpreting fields, this can lead to incorrect output.
>Number: 1018
>Category: bin
>Synopsis: calendar does not check for end of string when interpreting fields, this can lead to incorrect output.
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu May 04 09:05:03 +0000 1995
>Closed-Date: Fri Jun 20 08:11:44 +0000 1997
>Last-Modified: Fri Jun 20 08:12:06 +0000 1997
>Originator: Douglas Crosher
>Release: NetBSD-current 4/5/1995
>Organization:
Swinburne University
>Environment:
System: NetBSD dtc-pc 1.0A NetBSD 1.0A (DTC) #0: Sun Apr 30 07:05:34 EST 1995 dtc@dtc-pc:/usr/src/sys/arch/i386/compile/DTC i386
>Description:
The routine which calendar uses to check for a current date in
the calendar files does not check for an end of string. This can
cause problems because for some possible input lines the routine can
continue past the end of the string. This subsequently leads to the
possibility of these lines being mis-interpreted and mistakenly output
as valid day entries.
>How-To-Repeat:
I encountered the problem after upgrading to current and found
that the mail messages produced by 'calendar -a' were incorrect.
I could reproduce the problem by creating a calendar file in
my home directory consisting of a single line of '%'s, and perhaps a
valid date. When 'calendar -a' was run it outputs the line of '%'s.
>Fix:
I have included a patch below which adds checking for an end of string
to the field searching routines; this fixes the problem.
*** calendar.c.orig Mon Mar 27 22:05:00 1995
--- calendar.c Thu May 4 05:48:02 1995
***************
*** 254,260 ****
int val;
char *start, savech;
! for (; !isdigit(*p) && !isalpha(*p) && *p != '*'; ++p);
if (*p == '*') { /* `*' is current month */
*flags |= F_ISMONTH;
*endp = p+1;
--- 254,260 ----
int val;
char *start, savech;
! for (; *p != '\0' && !isdigit(*p) && !isalpha(*p) && *p != '*'; ++p);
if (*p == '*') { /* `*' is current month */
*flags |= F_ISMONTH;
*endp = p+1;
***************
*** 262,272 ****
}
if (isdigit(*p)) {
val = strtol(p, &p, 10); /* if 0, it's failure */
! for (; !isdigit(*p) && !isalpha(*p) && *p != '*'; ++p);
*endp = p;
return (val);
}
! for (start = p; isalpha(*++p););
savech = *p;
*p = '\0';
if ((val = getmonth(start)) != 0)
--- 262,272 ----
}
if (isdigit(*p)) {
val = strtol(p, &p, 10); /* if 0, it's failure */
! for (; *p != '\0' && !isdigit(*p) && !isalpha(*p) && *p != '*'; ++p);
*endp = p;
return (val);
}
! for (start = p; *p != '\0' && isalpha(*++p););
savech = *p;
*p = '\0';
if ((val = getmonth(start)) != 0)
***************
*** 277,283 ****
*p = savech;
return (0);
}
! for (*p = savech; !isdigit(*p) && !isalpha(*p) && *p != '*'; ++p);
*endp = p;
return (val);
}
--- 277,283 ----
*p = savech;
return (0);
}
! for (*p = savech; *p!='\0' && !isdigit(*p) && !isalpha(*p) && *p != '*'; ++p);
*endp = p;
return (val);
}
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: lukem
State-Changed-When: Fri Jun 20 01:11:44 PDT 1997
State-Changed-Why:
fixed - thanks!
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.