[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

library/2215: strptime() problems




>Number:         2215
>Category:       library
>Synopsis:       strptime() problems
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 28 16:10:01 MST 2001
>Last-Modified:
>Originator:     Niclas Sodergard
>Organization:
net
>Release:        2.9
>Environment:
	
	System      : OpenBSD 2.9
	Architecture: OpenBSD.i386
	Machine     : i386
>Description:
        strptime() can't handle the string %Y%m%d%H%M%S even though
        the input string is correct. I included a small C program
        which shows the problem.
        Can't really upgrade the machine to 3.0 so I don't know if
        the bug is still there but I checked the CVS and the code
        hadn't been changed for a while.
	
>How-To-Repeat:
#include <time.h>
#include <stdio.h>

int main(void)
{
    time_t mytime;
    char timebuf[32];
    struct tm convtime;

    mytime = time(NULL);
    if(strftime(timebuf, 32, "%Y%m%d%H%M%S", gmtime(&mytime))) {
        puts(timebuf);
        if(strptime(timebuf, "%Y%m%d%H%M%S", &convtime))
            puts("Worked");
        else
            puts("strptime failed");
    } else
        puts("Couldn't convert time");
}
	
>Fix:
	

>Audit-Trail:
>Unformatted: