diff options
| author | beck <> | 2002-06-07 03:45:34 +0000 |
|---|---|---|
| committer | beck <> | 2002-06-07 03:45:34 +0000 |
| commit | 820a20ea2b5f97e4a8fb714fedf33edafd40740a (patch) | |
| tree | 595b35cf9e1ff104d11fb8ab64ebb6a5c5f42755 /src/lib/libcrypto/asn1 | |
| parent | d13d58e31ac54f9b283fe3ec100f31030e050fb4 (diff) | |
| download | openbsd-820a20ea2b5f97e4a8fb714fedf33edafd40740a.tar.gz openbsd-820a20ea2b5f97e4a8fb714fedf33edafd40740a.tar.bz2 openbsd-820a20ea2b5f97e4a8fb714fedf33edafd40740a.zip | |
Merge OpenSSL 0.9.7-stable-20020605,
correctly autogenerate obj_mac.h
Diffstat (limited to 'src/lib/libcrypto/asn1')
| -rw-r--r-- | src/lib/libcrypto/asn1/a_bitstr.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/asn1/a_enum.c | 12 | ||||
| -rw-r--r-- | src/lib/libcrypto/asn1/a_int.c | 11 | ||||
| -rw-r--r-- | src/lib/libcrypto/asn1/a_set.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/asn1/a_utctm.c | 3 | ||||
| -rw-r--r-- | src/lib/libcrypto/asn1/x_pubkey.c | 10 |
6 files changed, 36 insertions, 10 deletions
diff --git a/src/lib/libcrypto/asn1/a_bitstr.c b/src/lib/libcrypto/asn1/a_bitstr.c index c36817c1ee..ed0bdfbde1 100644 --- a/src/lib/libcrypto/asn1/a_bitstr.c +++ b/src/lib/libcrypto/asn1/a_bitstr.c | |||
| @@ -71,8 +71,6 @@ int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp) | |||
| 71 | if (a == NULL) return(0); | 71 | if (a == NULL) return(0); |
| 72 | 72 | ||
| 73 | len=a->length; | 73 | len=a->length; |
| 74 | ret=1+len; | ||
| 75 | if (pp == NULL) return(ret); | ||
| 76 | 74 | ||
| 77 | if (len > 0) | 75 | if (len > 0) |
| 78 | { | 76 | { |
| @@ -100,6 +98,10 @@ int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp) | |||
| 100 | } | 98 | } |
| 101 | else | 99 | else |
| 102 | bits=0; | 100 | bits=0; |
| 101 | |||
| 102 | ret=1+len; | ||
| 103 | if (pp == NULL) return(ret); | ||
| 104 | |||
| 103 | p= *pp; | 105 | p= *pp; |
| 104 | 106 | ||
| 105 | *(p++)=(unsigned char)bits; | 107 | *(p++)=(unsigned char)bits; |
diff --git a/src/lib/libcrypto/asn1/a_enum.c b/src/lib/libcrypto/asn1/a_enum.c index 8a315fa371..ad8f0ffd1a 100644 --- a/src/lib/libcrypto/asn1/a_enum.c +++ b/src/lib/libcrypto/asn1/a_enum.c | |||
| @@ -151,7 +151,17 @@ ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai) | |||
| 151 | else ret->type=V_ASN1_ENUMERATED; | 151 | else ret->type=V_ASN1_ENUMERATED; |
| 152 | j=BN_num_bits(bn); | 152 | j=BN_num_bits(bn); |
| 153 | len=((j == 0)?0:((j/8)+1)); | 153 | len=((j == 0)?0:((j/8)+1)); |
| 154 | ret->data=(unsigned char *)OPENSSL_malloc(len+4); | 154 | if (ret->length < len+4) |
| 155 | { | ||
| 156 | unsigned char *new_data=OPENSSL_realloc(ret->data, len+4); | ||
| 157 | if (!new_data) | ||
| 158 | { | ||
| 159 | ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_MALLOC_FAILURE); | ||
| 160 | goto err; | ||
| 161 | } | ||
| 162 | ret->data=new_data; | ||
| 163 | } | ||
| 164 | |||
| 155 | ret->length=BN_bn2bin(bn,ret->data); | 165 | ret->length=BN_bn2bin(bn,ret->data); |
| 156 | return(ret); | 166 | return(ret); |
| 157 | err: | 167 | err: |
diff --git a/src/lib/libcrypto/asn1/a_int.c b/src/lib/libcrypto/asn1/a_int.c index 496704b9a5..edb243c021 100644 --- a/src/lib/libcrypto/asn1/a_int.c +++ b/src/lib/libcrypto/asn1/a_int.c | |||
| @@ -397,7 +397,16 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai) | |||
| 397 | else ret->type=V_ASN1_INTEGER; | 397 | else ret->type=V_ASN1_INTEGER; |
| 398 | j=BN_num_bits(bn); | 398 | j=BN_num_bits(bn); |
| 399 | len=((j == 0)?0:((j/8)+1)); | 399 | len=((j == 0)?0:((j/8)+1)); |
| 400 | ret->data=(unsigned char *)OPENSSL_malloc(len+4); | 400 | if (ret->length < len+4) |
| 401 | { | ||
| 402 | unsigned char *new_data=OPENSSL_realloc(ret->data, len+4); | ||
| 403 | if (!new_data) | ||
| 404 | { | ||
| 405 | ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_MALLOC_FAILURE); | ||
| 406 | goto err; | ||
| 407 | } | ||
| 408 | ret->data=new_data; | ||
| 409 | } | ||
| 401 | ret->length=BN_bn2bin(bn,ret->data); | 410 | ret->length=BN_bn2bin(bn,ret->data); |
| 402 | /* Correct zero case */ | 411 | /* Correct zero case */ |
| 403 | if(!ret->length) | 412 | if(!ret->length) |
diff --git a/src/lib/libcrypto/asn1/a_set.c b/src/lib/libcrypto/asn1/a_set.c index 19bb60fca8..0f839822ff 100644 --- a/src/lib/libcrypto/asn1/a_set.c +++ b/src/lib/libcrypto/asn1/a_set.c | |||
| @@ -118,7 +118,7 @@ int i2d_ASN1_SET(STACK *a, unsigned char **pp, int (*func)(), int ex_tag, | |||
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | pStart = p; /* Catch the beg of Setblobs*/ | 120 | pStart = p; /* Catch the beg of Setblobs*/ |
| 121 | rgSetBlob = (MYBLOB *)OPENSSL_malloc( sk_num(a) * sizeof(MYBLOB)); /* In this array | 121 | if (!(rgSetBlob = (MYBLOB *)OPENSSL_malloc( sk_num(a) * sizeof(MYBLOB)))) return 0; /* In this array |
| 122 | we will store the SET blobs */ | 122 | we will store the SET blobs */ |
| 123 | 123 | ||
| 124 | for (i=0; i<sk_num(a); i++) | 124 | for (i=0; i<sk_num(a); i++) |
| @@ -135,7 +135,7 @@ SetBlob | |||
| 135 | /* Now we have to sort the blobs. I am using a simple algo. | 135 | /* Now we have to sort the blobs. I am using a simple algo. |
| 136 | *Sort ptrs *Copy to temp-mem *Copy from temp-mem to user-mem*/ | 136 | *Sort ptrs *Copy to temp-mem *Copy from temp-mem to user-mem*/ |
| 137 | qsort( rgSetBlob, sk_num(a), sizeof(MYBLOB), SetBlobCmp); | 137 | qsort( rgSetBlob, sk_num(a), sizeof(MYBLOB), SetBlobCmp); |
| 138 | pTempMem = OPENSSL_malloc(totSize); | 138 | if (!(pTempMem = OPENSSL_malloc(totSize))) return 0; |
| 139 | 139 | ||
| 140 | /* Copy to temp mem */ | 140 | /* Copy to temp mem */ |
| 141 | p = pTempMem; | 141 | p = pTempMem; |
diff --git a/src/lib/libcrypto/asn1/a_utctm.c b/src/lib/libcrypto/asn1/a_utctm.c index ed2d827db2..dbb4a42c9d 100644 --- a/src/lib/libcrypto/asn1/a_utctm.c +++ b/src/lib/libcrypto/asn1/a_utctm.c | |||
| @@ -222,6 +222,7 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t) | |||
| 222 | int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t) | 222 | int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t) |
| 223 | { | 223 | { |
| 224 | struct tm *tm; | 224 | struct tm *tm; |
| 225 | struct tm data; | ||
| 225 | int offset; | 226 | int offset; |
| 226 | int year; | 227 | int year; |
| 227 | 228 | ||
| @@ -238,7 +239,7 @@ int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t) | |||
| 238 | 239 | ||
| 239 | t -= offset*60; /* FIXME: may overflow in extreme cases */ | 240 | t -= offset*60; /* FIXME: may overflow in extreme cases */ |
| 240 | 241 | ||
| 241 | { struct tm data; tm = OPENSSL_gmtime(&t, &data); } | 242 | tm = OPENSSL_gmtime(&t, &data); |
| 242 | 243 | ||
| 243 | #define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1 | 244 | #define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1 |
| 244 | year = g2(s->data); | 245 | year = g2(s->data); |
diff --git a/src/lib/libcrypto/asn1/x_pubkey.c b/src/lib/libcrypto/asn1/x_pubkey.c index 55630294b6..d958540120 100644 --- a/src/lib/libcrypto/asn1/x_pubkey.c +++ b/src/lib/libcrypto/asn1/x_pubkey.c | |||
| @@ -84,7 +84,7 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey) | |||
| 84 | X509_PUBKEY *pk; | 84 | X509_PUBKEY *pk; |
| 85 | X509_ALGOR *a; | 85 | X509_ALGOR *a; |
| 86 | ASN1_OBJECT *o; | 86 | ASN1_OBJECT *o; |
| 87 | unsigned char *s,*p; | 87 | unsigned char *s,*p = NULL; |
| 88 | int i; | 88 | int i; |
| 89 | 89 | ||
| 90 | if (x == NULL) return(0); | 90 | if (x == NULL) return(0); |
| @@ -119,7 +119,7 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey) | |||
| 119 | dsa->write_params=0; | 119 | dsa->write_params=0; |
| 120 | ASN1_TYPE_free(a->parameter); | 120 | ASN1_TYPE_free(a->parameter); |
| 121 | i=i2d_DSAparams(dsa,NULL); | 121 | i=i2d_DSAparams(dsa,NULL); |
| 122 | p=(unsigned char *)OPENSSL_malloc(i); | 122 | if ((p=(unsigned char *)OPENSSL_malloc(i)) == NULL) goto err; |
| 123 | pp=p; | 123 | pp=p; |
| 124 | i2d_DSAparams(dsa,&pp); | 124 | i2d_DSAparams(dsa,&pp); |
| 125 | a->parameter=ASN1_TYPE_new(); | 125 | a->parameter=ASN1_TYPE_new(); |
| @@ -136,7 +136,11 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey) | |||
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | if ((i=i2d_PublicKey(pkey,NULL)) <= 0) goto err; | 138 | if ((i=i2d_PublicKey(pkey,NULL)) <= 0) goto err; |
| 139 | if ((s=(unsigned char *)OPENSSL_malloc(i+1)) == NULL) goto err; | 139 | if ((s=(unsigned char *)OPENSSL_malloc(i+1)) == NULL) |
| 140 | { | ||
| 141 | X509err(X509_F_X509_PUBKEY_SET,ERR_R_MALLOC_FAILURE); | ||
| 142 | goto err; | ||
| 143 | } | ||
| 140 | p=s; | 144 | p=s; |
| 141 | i2d_PublicKey(pkey,&p); | 145 | i2d_PublicKey(pkey,&p); |
| 142 | if (!M_ASN1_BIT_STRING_set(pk->public_key,s,i)) goto err; | 146 | if (!M_ASN1_BIT_STRING_set(pk->public_key,s,i)) goto err; |
