proposed time zone package changes (revised)
Arthur David Olson
olsona at lecserver.nci.nih.gov
Sat Feb 6 19:49:10 UTC 2010
Here are the proposed changes, revised to incorporate KRE's suggestion
on how to handle NULLs passed to asctime_r.
--ado
------- asctime.c -------
*** /tmp/geta27327 Sat Feb 6 14:46:35 2010
--- /tmp/getb27327 Sat Feb 6 14:46:35 2010
***************
*** 11,17 ****
#ifndef lint
#ifndef NOID
! static char elsieid[] = "@(#)asctime.c 8.2";
#endif /* !defined NOID */
#endif /* !defined lint */
--- 11,17 ----
#ifndef lint
#ifndef NOID
! static char elsieid[] = "@(#)asctime.c 8.4";
#endif /* !defined NOID */
#endif /* !defined lint */
***************
*** 91,96 ****
--- 91,101 ----
char year[INT_STRLEN_MAXIMUM(int) + 2];
char result[MAX_ASCTIME_BUF_SIZE];
+ if (timeptr == NULL) {
+ errno = EINVAL;
+ (void) strcpy(buf, "??? ??? ?? ??:??:?? ????\n");
+ return buf;
+ }
if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK)
wn = "???";
else wn = wday_name[timeptr->tm_wday];
------- localtime.c -------
*** /tmp/geta27345 Sat Feb 6 14:46:35 2010
--- /tmp/getb27345 Sat Feb 6 14:46:35 2010
***************
*** 5,11 ****
#ifndef lint
#ifndef NOID
! static char elsieid[] = "@(#)localtime.c 8.9";
#endif /* !defined NOID */
#endif /* !defined lint */
--- 5,11 ----
#ifndef lint
#ifndef NOID
! static char elsieid[] = "@(#)localtime.c 8.10";
#endif /* !defined NOID */
#endif /* !defined lint */
***************
*** 1889,1894 ****
--- 1889,1898 ----
int types[TZ_MAX_TYPES];
int okay;
+ if (tmp == NULL) {
+ errno = EINVAL;
+ return WRONG;
+ }
if (tmp->tm_isdst > 1)
tmp->tm_isdst = 1;
t = time2(tmp, funcp, offset, &okay);
***************
*** 1960,1966 ****
timelocal(tmp)
struct tm * const tmp;
{
! tmp->tm_isdst = -1; /* in case it wasn't initialized */
return mktime(tmp);
}
--- 1964,1971 ----
timelocal(tmp)
struct tm * const tmp;
{
! if (tmp != NULL)
! tmp->tm_isdst = -1; /* in case it wasn't initialized */
return mktime(tmp);
}
***************
*** 1968,1974 ****
timegm(tmp)
struct tm * const tmp;
{
! tmp->tm_isdst = 0;
return time1(tmp, gmtsub, 0L);
}
--- 1973,1980 ----
timegm(tmp)
struct tm * const tmp;
{
! if (tmp != NULL)
! tmp->tm_isdst = 0;
return time1(tmp, gmtsub, 0L);
}
***************
*** 1977,1983 ****
struct tm * const tmp;
const long offset;
{
! tmp->tm_isdst = 0;
return time1(tmp, gmtsub, offset);
}
--- 1983,1990 ----
struct tm * const tmp;
const long offset;
{
! if (tmp != NULL)
! tmp->tm_isdst = 0;
return time1(tmp, gmtsub, offset);
}
More information about the tz
mailing list