Use basename of objxref.pl not whole path in generated header.
[oweals/openssl.git] / crypto / asn1 / a_utctm.c
index efebc63a026441bc52bf1e5f80918b7ce3e4647f..072e23659233479ce32b756276276638d95466a6 100644 (file)
@@ -114,8 +114,8 @@ err:
 
 int ASN1_UTCTIME_check(ASN1_UTCTIME *d)
        {
-       static int min[8]={ 0, 1, 1, 0, 0, 0, 0, 0};
-       static int max[8]={99,12,31,23,59,59,12,59};
+       static const int min[8]={ 0, 1, 1, 0, 0, 0, 0, 0};
+       static const int max[8]={99,12,31,23,59,59,12,59};
        char *a;
        int n,i,l,o;
 
@@ -186,6 +186,12 @@ int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str)
 
 ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
        {
+       return ASN1_UTCTIME_adj(s, t, 0, 0);
+       }
+
+ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
+                               int offset_day, long offset_sec)
+       {
        char *p;
        struct tm *ts;
        struct tm data;
@@ -200,16 +206,24 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
        if (ts == NULL)
                return(NULL);
 
+       if (offset_day || offset_sec)
+               { 
+               if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
+                       return NULL;
+               }
+
+       if((ts->tm_year < 50) || (ts->tm_year >= 150))
+               return NULL;
+
        p=(char *)s->data;
        if ((p == NULL) || ((size_t)s->length < len))
                {
                p=OPENSSL_malloc(len);
                if (p == NULL)
                        {
-                       ASN1err(ASN1_F_ASN1_UTCTIME_SET,ERR_R_MALLOC_FAILURE);
+                       ASN1err(ASN1_F_ASN1_UTCTIME_ADJ,ERR_R_MALLOC_FAILURE);
                        return(NULL);
                        }
-               if (s->data != NULL)
                if (s->data != NULL)
                        OPENSSL_free(s->data);
                s->data=(unsigned char *)p;