Check return value of gmtime() and add error codes

where it fails in ASN1_TIME_set().

Clear error queue in req.c if *_min or *_max is absent.
This commit is contained in:
Dr. Stephen Henson 2003-01-24 00:42:50 +00:00
parent 246f2b016b
commit 624feae8af
6 changed files with 20 additions and 2 deletions

View File

@ -4,6 +4,10 @@
Changes between 0.9.7 and 0.9.7a [XX xxx 2003] Changes between 0.9.7 and 0.9.7a [XX xxx 2003]
*) Under Win32 gmtime() can return NULL: check return value in
OPENSSL_gmtime(). Add error code for case where gmtime() fails.
[Steve Henson]
*) DSA routines: under certain error conditions uninitialized BN objects *) DSA routines: under certain error conditions uninitialized BN objects
could be freed. Solution: make sure initialization is performed early could be freed. Solution: make sure initialization is performed early
enough. (Reported and fix supplied by Ivan D Nestlerode <nestler@MIT.EDU>, enough. (Reported and fix supplied by Ivan D Nestlerode <nestler@MIT.EDU>,

View File

@ -1237,11 +1237,17 @@ start: for (;;)
sprintf(buf,"%s_min",v->name); sprintf(buf,"%s_min",v->name);
if (!NCONF_get_number(req_conf,dn_sect,buf, &n_min)) if (!NCONF_get_number(req_conf,dn_sect,buf, &n_min))
{
ERR_clear_error();
n_min = -1; n_min = -1;
}
sprintf(buf,"%s_max",v->name); sprintf(buf,"%s_max",v->name);
if (!NCONF_get_number(req_conf,dn_sect,buf, &n_max)) if (!NCONF_get_number(req_conf,dn_sect,buf, &n_max))
{
ERR_clear_error();
n_max = -1; n_max = -1;
}
if (!add_DN_object(subj,v->value,def,value,nid, if (!add_DN_object(subj,v->value,def,value,nid,
n_min,n_max, chtype)) n_min,n_max, chtype))

View File

@ -105,7 +105,10 @@ ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t)
ts=OPENSSL_gmtime(&t,&data); ts=OPENSSL_gmtime(&t,&data);
if (ts == NULL) if (ts == NULL)
{
ASN1err(ASN1_F_ASN1_TIME_SET, ASN1_R_ERROR_GETTING_TIME);
return NULL; return NULL;
}
if((ts->tm_year >= 50) && (ts->tm_year < 150)) if((ts->tm_year >= 50) && (ts->tm_year < 150))
return ASN1_UTCTIME_set(s, t); return ASN1_UTCTIME_set(s, t);
return ASN1_GENERALIZEDTIME_set(s,t); return ASN1_GENERALIZEDTIME_set(s,t);

View File

@ -980,6 +980,7 @@ void ERR_load_ASN1_strings(void);
#define ASN1_F_ASN1_TEMPLATE_D2I 131 #define ASN1_F_ASN1_TEMPLATE_D2I 131
#define ASN1_F_ASN1_TEMPLATE_EX_D2I 132 #define ASN1_F_ASN1_TEMPLATE_EX_D2I 132
#define ASN1_F_ASN1_TEMPLATE_NEW 133 #define ASN1_F_ASN1_TEMPLATE_NEW 133
#define ASN1_F_ASN1_TIME_SET 175
#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134 #define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134
#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135 #define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135
#define ASN1_F_ASN1_UNPACK_STRING 136 #define ASN1_F_ASN1_UNPACK_STRING 136
@ -1037,6 +1038,7 @@ void ERR_load_ASN1_strings(void);
#define ASN1_R_DECODE_ERROR 110 #define ASN1_R_DECODE_ERROR 110
#define ASN1_R_DECODING_ERROR 111 #define ASN1_R_DECODING_ERROR 111
#define ASN1_R_ENCODE_ERROR 112 #define ASN1_R_ENCODE_ERROR 112
#define ASN1_R_ERROR_GETTING_TIME 173
#define ASN1_R_ERROR_LOADING_SECTION 172 #define ASN1_R_ERROR_LOADING_SECTION 172
#define ASN1_R_ERROR_PARSING_SET_ELEMENT 113 #define ASN1_R_ERROR_PARSING_SET_ELEMENT 113
#define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114 #define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114

View File

@ -1,6 +1,6 @@
/* crypto/asn1/asn1_err.c */ /* crypto/asn1/asn1_err.c */
/* ==================================================================== /* ====================================================================
* Copyright (c) 1999 The OpenSSL Project. All rights reserved. * Copyright (c) 1999-2002 The OpenSSL Project. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -100,6 +100,7 @@ static ERR_STRING_DATA ASN1_str_functs[]=
{ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_D2I,0), "ASN1_TEMPLATE_D2I"}, {ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_D2I,0), "ASN1_TEMPLATE_D2I"},
{ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_EX_D2I,0), "ASN1_TEMPLATE_EX_D2I"}, {ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_EX_D2I,0), "ASN1_TEMPLATE_EX_D2I"},
{ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_NEW,0), "ASN1_TEMPLATE_NEW"}, {ERR_PACK(0,ASN1_F_ASN1_TEMPLATE_NEW,0), "ASN1_TEMPLATE_NEW"},
{ERR_PACK(0,ASN1_F_ASN1_TIME_SET,0), "ASN1_TIME_set"},
{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,0), "ASN1_TYPE_get_int_octetstring"}, {ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING,0), "ASN1_TYPE_get_int_octetstring"},
{ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_OCTETSTRING,0), "ASN1_TYPE_get_octetstring"}, {ERR_PACK(0,ASN1_F_ASN1_TYPE_GET_OCTETSTRING,0), "ASN1_TYPE_get_octetstring"},
{ERR_PACK(0,ASN1_F_ASN1_UNPACK_STRING,0), "ASN1_unpack_string"}, {ERR_PACK(0,ASN1_F_ASN1_UNPACK_STRING,0), "ASN1_unpack_string"},
@ -160,6 +161,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
{ASN1_R_DECODE_ERROR ,"decode error"}, {ASN1_R_DECODE_ERROR ,"decode error"},
{ASN1_R_DECODING_ERROR ,"decoding error"}, {ASN1_R_DECODING_ERROR ,"decoding error"},
{ASN1_R_ENCODE_ERROR ,"encode error"}, {ASN1_R_ENCODE_ERROR ,"encode error"},
{ASN1_R_ERROR_GETTING_TIME ,"error getting time"},
{ASN1_R_ERROR_LOADING_SECTION ,"error loading section"}, {ASN1_R_ERROR_LOADING_SECTION ,"error loading section"},
{ASN1_R_ERROR_PARSING_SET_ELEMENT ,"error parsing set element"}, {ASN1_R_ERROR_PARSING_SET_ELEMENT ,"error parsing set element"},
{ASN1_R_ERROR_SETTING_CIPHER_PARAMS ,"error setting cipher params"}, {ASN1_R_ERROR_SETTING_CIPHER_PARAMS ,"error setting cipher params"},

View File

@ -80,6 +80,7 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
ts = result; ts = result;
#elif !defined(OPENSSL_SYS_VMS) #elif !defined(OPENSSL_SYS_VMS)
ts = gmtime(timer); ts = gmtime(timer);
if (ts != NULL)
memcpy(result, ts, sizeof(struct tm)); memcpy(result, ts, sizeof(struct tm));
ts = result; ts = result;
#endif #endif