Bug#162917: libc6: strftime crashes with invalid input
Package: libc6
Version: 2.2.5-14.3
Severity: normal
strftime() causes a segmentation fault if some of the values in the tm
argument are outside of its expected range. Here is a sample program:
#include <stdio.h>
#include <time.h>
int main() {
struct tm tmStruct;
char buf[256];
tmStruct.tm_year = 0;
tmStruct.tm_mon = 0;
tmStruct.tm_mday = 1;
tmStruct.tm_hour = 0;
tmStruct.tm_min = 0;
tmStruct.tm_sec = 0;
/* here is the problem: tm_wday is set to -1; I initially
* encountered this because I was setting tm_wday to -1 and then
* calling mktime, and not checking the return value from mktime
* before calling strftime */
tmStruct.tm_wday = -1;
tmStruct.tm_yday = 0;
tmStruct.tm_isdst = 0;
strftime(buf, sizeof(buf), "%c", &tmStruct);
return 0;
}
-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux silly 2.2.18 #1 SMP Tue Nov 6 21:32:32 EST 2001 i586
Locale: LANG=en_AU, LC_CTYPE=en_AU
Versions of packages libc6 depends on:
ii libdb1-compat 2.1.3-5 The Berkeley database routines [gl
-- no debconf information
Reply to: