summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/bio_md.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/evp/bio_md.c')
-rw-r--r--src/lib/libcrypto/evp/bio_md.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/lib/libcrypto/evp/bio_md.c b/src/lib/libcrypto/evp/bio_md.c
index ed5c1135fd..9841e32e1a 100644
--- a/src/lib/libcrypto/evp/bio_md.c
+++ b/src/lib/libcrypto/evp/bio_md.c
@@ -130,8 +130,8 @@ static int md_read(BIO *b, char *out, int outl)
130 { 130 {
131 if (ret > 0) 131 if (ret > 0)
132 { 132 {
133 EVP_DigestUpdate(ctx,(unsigned char *)out, 133 if (EVP_DigestUpdate(ctx,(unsigned char *)out,
134 (unsigned int)ret); 134 (unsigned int)ret)<=0) return (-1);
135 } 135 }
136 } 136 }
137 BIO_clear_retry_flags(b); 137 BIO_clear_retry_flags(b);
@@ -157,8 +157,11 @@ static int md_write(BIO *b, const char *in, int inl)
157 (unsigned int)ret); 157 (unsigned int)ret);
158 } 158 }
159 } 159 }
160 BIO_clear_retry_flags(b); 160 if(b->next_bio != NULL)
161 BIO_copy_next_retry(b); 161 {
162 BIO_clear_retry_flags(b);
163 BIO_copy_next_retry(b);
164 }
162 return(ret); 165 return(ret);
163 } 166 }
164 167
@@ -194,6 +197,7 @@ static long md_ctrl(BIO *b, int cmd, long num, void *ptr)
194 case BIO_C_GET_MD_CTX: 197 case BIO_C_GET_MD_CTX:
195 pctx=ptr; 198 pctx=ptr;
196 *pctx=ctx; 199 *pctx=ctx;
200 b->init = 1;
197 break; 201 break;
198 case BIO_C_SET_MD_CTX: 202 case BIO_C_SET_MD_CTX:
199 if (b->init) 203 if (b->init)
@@ -249,7 +253,9 @@ static int md_gets(BIO *bp, char *buf, int size)
249 ctx=bp->ptr; 253 ctx=bp->ptr;
250 if (size < ctx->digest->md_size) 254 if (size < ctx->digest->md_size)
251 return(0); 255 return(0);
252 EVP_DigestFinal_ex(ctx,(unsigned char *)buf,&ret); 256 if (EVP_DigestFinal_ex(ctx,(unsigned char *)buf,&ret)<=0)
257 return -1;
258
253 return((int)ret); 259 return((int)ret);
254 } 260 }
255 261