NetBSD Problem Report #7001
Received: (qmail 4827 invoked from network); 14 Feb 1999 08:28:35 -0000
Message-Id: <199902140829.RAA00798@gee>
Date: Sun, 14 Feb 1999 17:29:56 +0900 (JST)
From: mochid@yo.rim.or.jp
To: gnats-bugs@gnats.netbsd.org
Subject: strptime(3) takes 3 chars for %M
X-Send-Pr-Version: 3.95
>Number: 7001
>Category: lib
>Synopsis: strptime(3) takes 3 chars for %M
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: lib-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Feb 14 00:35:00 +0000 1999
>Closed-Date: Thu Apr 29 03:03:28 +0000 1999
>Last-Modified: Thu Apr 29 03:03:49 +0000 1999
>Originator: MOCHIDA Shuji
>Release: Feb 14 1999
>Organization:
parsonal
>Environment:
System: NetBSD gee 1.3.3 NetBSD 1.3.3 (GEE2) #0: Sat Jan 9 23:45:20 JST 1999 mochid@gee:/var/tmp/NetBSD/133/usr/src/sys/arch/i386/compile/GEE2 i386
>Description:
strptime("990214010101", "%y%m%d%H%M%S", &tm);
^^^
takes "010" for '%M'
>How-To-Repeat:
/* strptimetest.c */
#include <time.h>
int main(argc, argv)
int argc;
char* argv[];
{
struct tm tm;
memset(&tm, 0, sizeof(tm));
strptime(argv[1], argv[2], &tm);
printf("hour: %d, min: %d, sec: %d\n", tm.tm_hour, tm.tm_min, tm.tm_sec);
return 0;
}
% make strptimetest
% ./strptimetest "990214010101" "%y%m%d%H%M%S"
hour: 10, min: 10, sec: 1
>Fix:
work around:
--- strptime.c.ORIG Mon Nov 16 08:28:10 1998
+++ strptime.c Sun Feb 14 17:10:28 1999
@@ -321,7 +321,7 @@
case 'Y': /* The year. */
LEGAL_ALT(ALT_E);
- if (!(conv_num(&bp, &i, 0, INT_MAX)))
+ if (!(conv_num(&bp, &i, 0, 9999)))
return (0);
tm->tm_year = i - TM_YEAR_BASE;
@@ -372,6 +372,8 @@
int *dest;
int llim, ulim;
{
+ int rulim = ulim;
+
*dest = 0;
if (**buf < '0' || **buf > '9')
@@ -380,7 +382,8 @@
do {
*dest *= 10;
*dest += *(*buf)++ - '0';
- } while ((*dest * 10 <= ulim) && **buf >= '0' && **buf <= '9');
+ rulim /= 10;
+ } while ((*dest * 10 <= ulim) && rulim && **buf >= '0' && **buf <= '9');
if (*dest < llim || *dest > ulim)
return (0);
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: tv
State-Changed-When: Wed Apr 28 20:03:28 PDT 1999
State-Changed-Why:
Fixed. A pullup request has been submitted for 1.4.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.