summaryrefslogtreecommitdiffstats
path: root/crypto/openssl/crypto/asn1/a_gentm.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/openssl/crypto/asn1/a_gentm.c')
-rw-r--r--crypto/openssl/crypto/asn1/a_gentm.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/crypto/openssl/crypto/asn1/a_gentm.c b/crypto/openssl/crypto/asn1/a_gentm.c
index b55f882..cd09f68 100644
--- a/crypto/openssl/crypto/asn1/a_gentm.c
+++ b/crypto/openssl/crypto/asn1/a_gentm.c
@@ -61,13 +61,10 @@
#include <stdio.h>
#include <time.h>
#include "cryptlib.h"
+#include "o_time.h"
#include <openssl/asn1.h>
-ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_new(void)
-{ return M_ASN1_GENERALIZEDTIME_new(); }
-
-void ASN1_GENERALIZEDTIME_free(ASN1_GENERALIZEDTIME *x)
-{ M_ASN1_GENERALIZEDTIME_free(x); }
+#if 0
int i2d_ASN1_GENERALIZEDTIME(ASN1_GENERALIZEDTIME *a, unsigned char **pp)
{
@@ -116,6 +113,8 @@ err:
return(NULL);
}
+#endif
+
int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d)
{
static int min[9]={ 0, 0, 1, 1, 0, 0, 0, 0, 0};
@@ -147,6 +146,19 @@ int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *d)
if ((n < min[i]) || (n > max[i])) goto err;
}
+ /* Optional fractional seconds: decimal point followed by one
+ * or more digits.
+ */
+ if (a[o] == '.')
+ {
+ if (++o > l) goto err;
+ i = o;
+ while ((a[o] >= '0') && (a[o] <= '9') && (o <= l))
+ o++;
+ /* Must have at least one digit after decimal point */
+ if (i == o) goto err;
+ }
+
if (a[o] == 'Z')
o++;
else if ((a[o] == '+') || (a[o] == '-'))
@@ -182,6 +194,7 @@ int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, char *str)
{
ASN1_STRING_set((ASN1_STRING *)s,
(unsigned char *)str,t.length);
+ s->type=V_ASN1_GENERALIZEDTIME;
}
return(1);
}
@@ -194,21 +207,17 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
{
char *p;
struct tm *ts;
-#if defined(THREADS) && !defined(WIN32)
struct tm data;
-#endif
if (s == NULL)
s=M_ASN1_GENERALIZEDTIME_new();
if (s == NULL)
return(NULL);
-#if defined(THREADS) && !defined(WIN32) && ! defined(_DARWIN)
- gmtime_r(&t,&data); /* should return &data, but doesn't on some systems, so we don't even look at the return value */
- ts=&data;
-#else
- ts=gmtime(&t);
-#endif
+ ts=OPENSSL_gmtime(&t, &data);
+ if (ts == NULL)
+ return(NULL);
+
p=(char *)s->data;
if ((p == NULL) || (s->length < 16))
{
OpenPOWER on IntegriCloud