diff options
author | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-01-16 13:52:05 +0000 |
---|---|---|
committer | Michal Rokos <m.rokos@sh.cvut.cz> | 2002-01-16 13:52:05 +0000 |
commit | 8717a87985a8b5fa3443ed9f5691f758d16d153a (patch) | |
tree | 14f0e5213472752d830d7fd3d9fe66cdd25ac8a1 | |
parent | f9fedb332a1f46758b1014a6ccf999b57dd3ff54 (diff) | |
download | ruby-openssl-history-8717a87985a8b5fa3443ed9f5691f758d16d153a.tar.gz |
* fixed missing/strptime.c (Hynek)
* more strict format for UTC time (ossl.c - 'Z' in the end)
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | missing/strptime.c | 26 | ||||
-rw-r--r-- | openssl_missing.c | 1 | ||||
-rw-r--r-- | ossl.c | 5 |
4 files changed, 25 insertions, 11 deletions
@@ -4,6 +4,10 @@ Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz> All rights reserved. $Log$ +Revision 1.26 2002/01/16 13:52:24 majkl + * fixed missing/strptime.c (Hynek) + * more strict format for UTC time (ossl.c - 'Z' in the end) + Revision 1.25 2002/01/16 12:12:50 majkl * selfdipatch BN implementation (test only) * removed strncasecmp (for WIN32 made alias to _strnicmp) diff --git a/missing/strptime.c b/missing/strptime.c index a8995e1..2ae4cbf 100644 --- a/missing/strptime.c +++ b/missing/strptime.c @@ -36,6 +36,14 @@ #include <ctype.h> #include <string.h> +#ifdef WIN32 +#define strncasecmp _strnicmp +#else +#ifndef HAVE_STRNCASECMP +# include "./strncasecmp.c" +#endif +#endif + /* #if !defined(WIN32) # include "common/config.h" @@ -85,9 +93,8 @@ strptime(char *buf, char *fmt, struct tm *tm) { char c, *ptr; - int i, + int i, j, len; - ptr = fmt; while (*ptr != 0) { if (*buf == 0) @@ -182,7 +189,7 @@ strptime(char *buf, char *fmt, struct tm *tm) if (!isdigit(*buf)) return 0; - for (i = 0; *buf != 0 && isdigit(*buf); buf++) { + for (j=0,i = 0; *buf != 0 && isdigit(*buf) && j<2; j++,buf++) { i *= 10; i += *buf - '0'; } @@ -206,7 +213,7 @@ strptime(char *buf, char *fmt, struct tm *tm) if (!isdigit(*buf)) return 0; - for (i = 0; *buf != 0 && isdigit(*buf); buf++) { + for (j=0,i = 0; *buf != 0 && isdigit(*buf) && j<2; j++,buf++) { i *= 10; i += *buf - '0'; } @@ -273,7 +280,7 @@ strptime(char *buf, char *fmt, struct tm *tm) if (!isdigit(*buf)) return 0; - for (i = 0; *buf != 0 && isdigit(*buf); buf++) { + for (j=0,i = 0; *buf != 0 && isdigit(*buf) && j<2; j++,buf++) { i *= 10; i += *buf - '0'; } @@ -314,7 +321,7 @@ strptime(char *buf, char *fmt, struct tm *tm) if (!isdigit(*buf)) return 0; - for (i = 0; *buf != 0 && isdigit(*buf); buf++) { + for (j=0,i = 0; *buf != 0 && isdigit(*buf) && j<2; j++,buf++) { i *= 10; i += *buf - '0'; } @@ -336,15 +343,16 @@ strptime(char *buf, char *fmt, struct tm *tm) if (!isdigit(*buf)) return 0; - for (i = 0; *buf != 0 && isdigit(*buf); buf++) { + for (j=0,i = 0; *buf != 0 && isdigit(*buf) && j<((c=='Y')?4:2); j++,buf++) { i *= 10; i += *buf - '0'; } - if (c == 'Y') + + if (c == 'Y') i -= 1900; else if (c < 69) /*c=='y', 00-68 is for 20xx, the rest is for 19xx*/ i += 100; - + if (i < 0) return 0; diff --git a/openssl_missing.c b/openssl_missing.c index f538a4e..592972b 100644 --- a/openssl_missing.c +++ b/openssl_missing.c @@ -10,6 +10,7 @@ */ #if !defined(NO_HMAC) && !defined(OPENSSL_NO_HMAC) +#include <string.h> #include <openssl/hmac.h> /* to hmac.[ch] */ @@ -57,12 +57,13 @@ asn1time_to_time(ASN1_UTCTIME *time) switch(time->type) { case V_ASN1_UTCTIME: - if (!strptime(time->data, "%y%m%d%H%M%S", &tm)) { + rb_warn("UTCTIME: %s", time->data); + if (!strptime(time->data, "%y%m%d%H%M%SZ", &tm)) { rb_raise(rb_eTypeError, "bad UTCTIME format"); } break; case V_ASN1_GENERALIZEDTIME: - if (!strptime(time->data, "%Y%m%d%H%M%S", &tm)) { + if (!strptime(time->data, "%Y%m%d%H%M%SZ", &tm)) { rb_raise(rb_eTypeError, "bad GENERALIZEDTIME format" ); } break; |