diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2002-12-03 23:50:59 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2002-12-03 23:50:59 +0000 |
commit | 2053c43de2575a0f72038b8a36146ef23c829885 (patch) | |
tree | 4ff8ac9167bf00247e7c5fcd611b4fb649bc5bcc /crypto/asn1/a_d2i_fp.c | |
parent | 1c3e4a366022c043ae87ff9715905e97582bf649 (diff) | |
download | openssl-2053c43de2575a0f72038b8a36146ef23c829885.tar.gz |
In asn1_d2i_read_bio, don't assume BIO_read will
return the requested number of bytes when reading
content.
Diffstat (limited to 'crypto/asn1/a_d2i_fp.c')
-rw-r--r-- | crypto/asn1/a_d2i_fp.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/crypto/asn1/a_d2i_fp.c b/crypto/asn1/a_d2i_fp.c index 71b4a28611..cfb56ae265 100644 --- a/crypto/asn1/a_d2i_fp.c +++ b/crypto/asn1/a_d2i_fp.c @@ -226,13 +226,18 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb) ASN1err(ASN1_F_ASN1_D2I_BIO,ERR_R_MALLOC_FAILURE); goto err; } - i=BIO_read(in,&(b->data[len]),want); - if (i <= 0) + while (want > 0) { - ASN1err(ASN1_F_ASN1_D2I_BIO,ASN1_R_NOT_ENOUGH_DATA); - goto err; + i=BIO_read(in,&(b->data[len]),want); + if (i <= 0) + { + ASN1err(ASN1_F_ASN1_D2I_BIO, + ASN1_R_NOT_ENOUGH_DATA); + goto err; + } + len+=i; + want -= i; } - len+=i; } off+=(int)c.slen; if (eos <= 0) |