diff options
author | Nils Larsch <nils@openssl.org> | 2005-07-26 20:55:17 +0000 |
---|---|---|
committer | Nils Larsch <nils@openssl.org> | 2005-07-26 20:55:17 +0000 |
commit | 3de6d65ea3cb3e8779494629260edc4b6874e2f8 (patch) | |
tree | 69eb243ccee1b02a2c4105576fcf060a06d249c6 /crypto/asn1 | |
parent | fdb0a6e0041a2ca941f1fc1084c028f73a9ef53b (diff) | |
download | openssl-new-3de6d65ea3cb3e8779494629260edc4b6874e2f8.tar.gz |
improved error checking and some fixes
PR: 1170
Submitted by: Yair Elharrar
Reviewed and edited by: Nils Larsch
Diffstat (limited to 'crypto/asn1')
-rw-r--r-- | crypto/asn1/a_bitstr.c | 4 | ||||
-rw-r--r-- | crypto/asn1/t_pkey.c | 18 |
2 files changed, 19 insertions, 3 deletions
diff --git a/crypto/asn1/a_bitstr.c b/crypto/asn1/a_bitstr.c index f621426d6f..0fb9ce0c2a 100644 --- a/crypto/asn1/a_bitstr.c +++ b/crypto/asn1/a_bitstr.c @@ -183,9 +183,11 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) iv= ~v; if (!value) v=0; + if (a == NULL) + return 0; + a->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear, set on write */ - if (a == NULL) return(0); if ((a->length < (w+1)) || (a->data == NULL)) { if (!value) return(1); /* Don't need to set */ diff --git a/crypto/asn1/t_pkey.c b/crypto/asn1/t_pkey.c index 939979f77d..296033d553 100644 --- a/crypto/asn1/t_pkey.c +++ b/crypto/asn1/t_pkey.c @@ -198,6 +198,11 @@ int DSA_print(BIO *bp, const DSA *x, int off) if (x->p) buf_len = (size_t)BN_num_bytes(x->p); + else + { + DSAerr(DSA_F_DSA_PRINT,DSA_R_MISSING_PARAMETERS); + goto err; + } if (x->q) if (buf_len < (i = (size_t)BN_num_bytes(x->q))) buf_len = i; @@ -670,6 +675,11 @@ int DHparams_print(BIO *bp, const DH *x) if (x->p) buf_len = (size_t)BN_num_bytes(x->p); + else + { + reason = ERR_R_PASSED_NULL_PARAMETER; + goto err; + } if (x->g) if (buf_len < (i = (size_t)BN_num_bytes(x->g))) buf_len = i; @@ -728,6 +738,11 @@ int DSAparams_print(BIO *bp, const DSA *x) if (x->p) buf_len = (size_t)BN_num_bytes(x->p); + else + { + DSAerr(DSA_F_DSA_PRINT,DSA_R_MISSING_PARAMETERS); + goto err; + } if (x->q) if (buf_len < (i = (size_t)BN_num_bytes(x->q))) buf_len = i; @@ -737,7 +752,7 @@ int DSAparams_print(BIO *bp, const DSA *x) m=(unsigned char *)OPENSSL_malloc(buf_len+10); if (m == NULL) { - reason=ERR_R_MALLOC_FAILURE; + DSAerr(DSA_F_DSA_PRINT,ERR_R_MALLOC_FAILURE); goto err; } @@ -750,7 +765,6 @@ int DSAparams_print(BIO *bp, const DSA *x) ret=1; err: if (m != NULL) OPENSSL_free(m); - DSAerr(DSA_F_DSAPARAMS_PRINT,reason); return(ret); } |