Date: Wed, 22 Sep 1999 15:29:45 -0400 (EDT) From: scott@chronis.pobox.com To: FreeBSD-gnats-submit@freebsd.org Subject: bin/13901: strptime breaks when handling some numerical fields Message-ID: <19990922192945.7BF689B46@chronis.pobox.com>
index | next in thread | raw e-mail
>Number: 13901
>Category: bin
>Synopsis: strptime breaks when handling some numerical fields
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Wed Sep 22 12:30:01 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator: scott
>Release: FreeBSD 3.3-STABLE i386
>Organization:
IC Group, Inc.
>Environment:
>Description:
Whenever a numeric data is expected by strptime() in it's `buf' argument,
it will allocate too many digits to any field which is followed by a
digit or string of digits in `buf'.
>How-To-Repeat:
#include <time.h>
struct tm t;
strptime("19990823", "%Y%m%d", &t); /* fails */
strptime("199911", "%Y11", &t); /* fails */
strptime("0711", "%m%d", &t); /* fails */
>Fix:
170c170,171
< for (i = 0; *buf != 0 && isdigit((unsigned char)*buf); buf++) {
---
> len = 0;
> for (i = 0; *buf != 0 && isdigit((unsigned char)*buf) && len < 3; buf++) {
172a174
> len++;
187,188c189,190
<
< for (i = 0; *buf != 0 && isdigit((unsigned char)*buf); buf++) {
---
> len = 0;
> for (i = 0; *buf != 0 && isdigit((unsigned char)*buf) && len < 2; buf++) {
190a193
> len++;
211,212c214,215
<
< for (i = 0; *buf != 0 && isdigit((unsigned char)*buf); buf++) {
---
> len = 0;
> for (i = 0; *buf != 0 && isdigit((unsigned char)*buf) && len < 2; buf++) {
214a218
> len++;
278,279c282,283
<
< for (i = 0; *buf != 0 && isdigit((unsigned char)*buf); buf++) {
---
> len = 0;
> for (i = 0; *buf != 0 && isdigit((unsigned char)*buf) && len < 2; buf++) {
281a286
> len++;
319,320c324,325
<
< for (i = 0; *buf != 0 && isdigit((unsigned char)*buf); buf++) {
---
> len = 0;
> for (i = 0; *buf != 0 && isdigit((unsigned char)*buf) && len < 2; buf++) {
322a328
> len++;
341a348
> len = 0;
344a352,356
> if ((c == 'y' && len >= 1) || (c == 'Y' && len >= 3)) {
> buf++;
> break;
> }
> len++;
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990922192945.7BF689B46>
