From owner-freebsd-bugs Tue Jun 22 5:50: 5 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id AA1F714F7C for ; Tue, 22 Jun 1999 05:50:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id FAA41607; Tue, 22 Jun 1999 05:50:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Date: Tue, 22 Jun 1999 05:50:02 -0700 (PDT) Message-Id: <199906221250.FAA41607@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Sheldon Hearn Subject: Re: bin/10131: bug in strptime(3) Reply-To: Sheldon Hearn Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR bin/10131; it has been noted by GNATS. From: Sheldon Hearn To: tadf@kt.rim.or.jp Cc: freebsd-gnats-submit@freebsd.org Subject: Re: bin/10131: bug in strptime(3) Date: Tue, 22 Jun 1999 14:45:36 +0200 For a patch this small, it's probably safe to include it directly, rather than uuencoding it. I've attached a plaintext copy here so that it gets into the PR as feedback. Note that the last hunk of the diff applies 2 lines offset. Be sure to send feedback if this diff is not being applied to CURRENT source (rev 1.6) as intended. Ciao, Sheldon. --- strptime.c.orig Sun Sep 13 07:20:40 1998 +++ strptime.c Mon Feb 15 00:34:16 1999 @@ -159,10 +159,10 @@ i *= 10; i += *buf - '0'; } - if (i > 365) + if (i < 1 || i > 366) return 0; - tm->tm_yday = i; + tm->tm_yday = i - 1; break; case 'M': @@ -177,8 +177,13 @@ i *= 10; i += *buf - '0'; } - if (i > 59) - return 0; + if (c == 'M') { + if (i > 59) + return 0; + } else { + if (i > 60) + return 0; + } if (c == 'M') tm->tm_min = i; @@ -259,6 +264,24 @@ buf += len; break; + case 'w': + if (!isdigit((unsigned char)*buf)) + return 0; + + for (i = 0; *buf != 0 && isdigit((unsigned char)*buf); buf++) { + i *= 10; + i += *buf - '0'; + } + if (i > 6) + return 0; + + tm->tm_wday = i; + + if (*buf != 0 && isspace((unsigned char)*buf)) + while (*ptr != 0 && !isspace((unsigned char)*ptr)) + ptr++; + break; + case 'd': case 'e': if (!isdigit((unsigned char)*buf)) @@ -337,6 +360,23 @@ return 0; tm->tm_year = i; + + if (*buf != 0 && isspace((unsigned char)*buf)) + while (*ptr != 0 && !isspace((unsigned char)*ptr)) + ptr++; + break; + + case 'U': + case 'W': + if (!isdigit((unsigned char)*buf)) + return 0; + + for (i = 0; *buf != 0 && isdigit((unsigned char)*buf); buf++) { + i *= 10; + i += *buf - '0'; + } + if (i > 53) + return 0; if (*buf != 0 && isspace((unsigned char)*buf)) while (*ptr != 0 && !isspace((unsigned char)*ptr)) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message