From: | Marc Culler |
Date: | 20 Aug 2000 at 21:46:40 |
Subject: | AMIOPEN: Bug in strftime |
With the "%z" format, /lib/strftime segfaults if given a date that falls
during the summer.
Try the code below. It will crash if you type in a number between 88 and 298:
- Marc Culler
#include <stdio.h>
#include <time.h>
int main(void)
{
time_t t;
struct tm *p;
int days;
char rfc822_zone[10];
puts("Enter a number of days since the epoch: ");
scanf("%d", &days);
t = (time_t)(days*24*3600);
p = localtime(&t);
printf("year: %d\n", 1900 + p->tm_year);
printf("month: %d\n", p->tm_mon);
printf("day: %d\n", p->tm_mday);
/* The call to strftime segfaults if the date falls in the summer! */
strftime(rfc822_zone, 10, "%z", p);
printf("rfc822 zone: %s\n", rfc822_zone);
}
Subscribe/Unsubscribe: open-request@amiga.com
Amiga FAQ: http://www.amiga.com/faq.html