diff options
Diffstat (limited to 'src/lib/libcrypto/bio')
-rw-r--r-- | src/lib/libcrypto/bio/bf_buff.c | 15 | ||||
-rw-r--r-- | src/lib/libcrypto/bio/bio.h | 9 |
2 files changed, 17 insertions, 7 deletions
diff --git a/src/lib/libcrypto/bio/bf_buff.c b/src/lib/libcrypto/bio/bf_buff.c index c1fd75aaad..4b5a132d8a 100644 --- a/src/lib/libcrypto/bio/bf_buff.c +++ b/src/lib/libcrypto/bio/bf_buff.c | |||
@@ -209,7 +209,7 @@ start: | |||
209 | /* add to buffer and return */ | 209 | /* add to buffer and return */ |
210 | if (i >= inl) | 210 | if (i >= inl) |
211 | { | 211 | { |
212 | memcpy(&(ctx->obuf[ctx->obuf_len]),in,inl); | 212 | memcpy(&(ctx->obuf[ctx->obuf_off+ctx->obuf_len]),in,inl); |
213 | ctx->obuf_len+=inl; | 213 | ctx->obuf_len+=inl; |
214 | return(num+inl); | 214 | return(num+inl); |
215 | } | 215 | } |
@@ -219,7 +219,7 @@ start: | |||
219 | { | 219 | { |
220 | if (i > 0) /* lets fill it up if we can */ | 220 | if (i > 0) /* lets fill it up if we can */ |
221 | { | 221 | { |
222 | memcpy(&(ctx->obuf[ctx->obuf_len]),in,i); | 222 | memcpy(&(ctx->obuf[ctx->obuf_off+ctx->obuf_len]),in,i); |
223 | in+=i; | 223 | in+=i; |
224 | inl-=i; | 224 | inl-=i; |
225 | num+=i; | 225 | num+=i; |
@@ -294,9 +294,9 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
294 | case BIO_C_GET_BUFF_NUM_LINES: | 294 | case BIO_C_GET_BUFF_NUM_LINES: |
295 | ret=0; | 295 | ret=0; |
296 | p1=ctx->ibuf; | 296 | p1=ctx->ibuf; |
297 | for (i=ctx->ibuf_off; i<ctx->ibuf_len; i++) | 297 | for (i=0; i<ctx->ibuf_len; i++) |
298 | { | 298 | { |
299 | if (p1[i] == '\n') ret++; | 299 | if (p1[ctx->ibuf_off + i] == '\n') ret++; |
300 | } | 300 | } |
301 | break; | 301 | break; |
302 | case BIO_CTRL_WPENDING: | 302 | case BIO_CTRL_WPENDING: |
@@ -399,17 +399,18 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
399 | for (;;) | 399 | for (;;) |
400 | { | 400 | { |
401 | BIO_clear_retry_flags(b); | 401 | BIO_clear_retry_flags(b); |
402 | if (ctx->obuf_len > ctx->obuf_off) | 402 | if (ctx->obuf_len > 0) |
403 | { | 403 | { |
404 | r=BIO_write(b->next_bio, | 404 | r=BIO_write(b->next_bio, |
405 | &(ctx->obuf[ctx->obuf_off]), | 405 | &(ctx->obuf[ctx->obuf_off]), |
406 | ctx->obuf_len-ctx->obuf_off); | 406 | ctx->obuf_len); |
407 | #if 0 | 407 | #if 0 |
408 | fprintf(stderr,"FLUSH [%3d] %3d -> %3d\n",ctx->obuf_off,ctx->obuf_len-ctx->obuf_off,r); | 408 | fprintf(stderr,"FLUSH [%3d] %3d -> %3d\n",ctx->obuf_off,ctx->obuf_len,r); |
409 | #endif | 409 | #endif |
410 | BIO_copy_next_retry(b); | 410 | BIO_copy_next_retry(b); |
411 | if (r <= 0) return((long)r); | 411 | if (r <= 0) return((long)r); |
412 | ctx->obuf_off+=r; | 412 | ctx->obuf_off+=r; |
413 | ctx->obuf_len-=r; | ||
413 | } | 414 | } |
414 | else | 415 | else |
415 | { | 416 | { |
diff --git a/src/lib/libcrypto/bio/bio.h b/src/lib/libcrypto/bio/bio.h index 152802fbdf..ab47abcf14 100644 --- a/src/lib/libcrypto/bio/bio.h +++ b/src/lib/libcrypto/bio/bio.h | |||
@@ -306,6 +306,15 @@ DECLARE_STACK_OF(BIO) | |||
306 | 306 | ||
307 | typedef struct bio_f_buffer_ctx_struct | 307 | typedef struct bio_f_buffer_ctx_struct |
308 | { | 308 | { |
309 | /* Buffers are setup like this: | ||
310 | * | ||
311 | * <---------------------- size -----------------------> | ||
312 | * +---------------------------------------------------+ | ||
313 | * | consumed | remaining | free space | | ||
314 | * +---------------------------------------------------+ | ||
315 | * <-- off --><------- len -------> | ||
316 | */ | ||
317 | |||
309 | /* BIO *bio; */ /* this is now in the BIO struct */ | 318 | /* BIO *bio; */ /* this is now in the BIO struct */ |
310 | int ibuf_size; /* how big is the input buffer */ | 319 | int ibuf_size; /* how big is the input buffer */ |
311 | int obuf_size; /* how big is the output buffer */ | 320 | int obuf_size; /* how big is the output buffer */ |