Subject: lib/6243: strptime(3) produces wrong results
To: None <gnats-bugs@gnats.netbsd.org>
From: Peter Simons <simons@petium.gmd.de>
List: netbsd-bugs
Date: 10/04/1998 21:20:26
>Number:         6243
>Category:       lib
>Synopsis:       strptime(3) produces wrong results
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct  4 12:35:00 1998
>Last-Modified:
>Originator:     Peter Simons
>Organization:
>Release:        NetBSD/i386 1.3
>Environment:
	
System: NetBSD petium.gmd.de 1.3 NetBSD 1.3 (PETIUM) #5: Tue Mar 24 18:00:04 CET 1998 simons@petium.rhein.de:/usr/src/sys/arch/i386/compile/PETIUM i386

>Description:
	strptime() produces incorrect data when creating the tm
	structure. If strptime() parses the month to be '10'
	(October), it writes the '10' into the tm structure. The
	tm_mon field in the tm structure, though, starts at zero!
	Hence the result is one month in the future.

>How-To-Repeat:
	#include <stdio.h>
	#include <time.h>

	int
	main()
	{
	    char buf[] = "10-04-1998";
	    struct tm tmp;
	    memset(&tmp, 0, sizeof(struct tm));

	    strptime(buf, "%m-%d-%Y", &tmp);
	    printf("%s", asctime(&tmp));
	    return 0;
	}

        | simons@petium:/tmp$ gcc test.c -o test && ./test
        | Sun Nov  4 00:00:00 1998

>Fix:
	
>Audit-Trail:
>Unformatted: