[fixed in 2.6] strptime() segfaults on certain date formats
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GLibC |
Fix Released
|
Medium
|
|||
glibc (Ubuntu) |
Fix Released
|
Medium
|
Unassigned |
Bug Description
This segfaults on Ubuntu Dapper:
#define _XOPEN_SOURCE
#include <time.h>
int main() {
struct tm tm;
strptime("2004", "%Y", &tm); /* Segfault. */
return 0;
}
This does not:
#define _XOPEN_SOURCE
#include <time.h>
int main() {
struct tm tm;
strptime(
strptime(
return 0;
}
Internally, strptime() sets up a "struct tm" when parsing the date string. If both the month and day-of-month are not present, two fields in that struct are left uninitialized, and the segfault occurs when the uninitialized values are used in an array lookup in time/strptime_
I have a patch for this, but cannot be sure that it works, because I don't have enough disk space or CPU time for a glibc build.
description: | updated |
Changed in glibc: | |
status: | Confirmed → Fix Committed |
Changed in glibc: | |
status: | Unknown → Fix Released |
Changed in glibc: | |
importance: | Unknown → Medium |
I can confirm this as well.