summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bio/bss_mem.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bio/bss_mem.c')
-rw-r--r--src/lib/libcrypto/bio/bss_mem.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/lib/libcrypto/bio/bss_mem.c b/src/lib/libcrypto/bio/bss_mem.c
index 41eab92415..28ff7582bf 100644
--- a/src/lib/libcrypto/bio/bss_mem.c
+++ b/src/lib/libcrypto/bio/bss_mem.c
@@ -61,11 +61,11 @@
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/bio.h> 62#include <openssl/bio.h>
63 63
64static int mem_write(BIO *h,char *buf,int num); 64static int mem_write(BIO *h, const char *buf, int num);
65static int mem_read(BIO *h,char *buf,int size); 65static int mem_read(BIO *h, char *buf, int size);
66static int mem_puts(BIO *h,char *str); 66static int mem_puts(BIO *h, const char *str);
67static int mem_gets(BIO *h,char *str,int size); 67static int mem_gets(BIO *h, char *str, int size);
68static long mem_ctrl(BIO *h,int cmd,long arg1,char *arg2); 68static long mem_ctrl(BIO *h, int cmd, long arg1, void *arg2);
69static int mem_new(BIO *h); 69static int mem_new(BIO *h);
70static int mem_free(BIO *data); 70static int mem_free(BIO *data);
71static BIO_METHOD mem_method= 71static BIO_METHOD mem_method=
@@ -163,14 +163,14 @@ static int mem_read(BIO *b, char *out, int outl)
163 } 163 }
164 } else if (bm->length == 0) 164 } else if (bm->length == 0)
165 { 165 {
166 if (b->num != 0) 166 ret = b->num;
167 if (ret != 0)
167 BIO_set_retry_read(b); 168 BIO_set_retry_read(b);
168 ret= b->num;
169 } 169 }
170 return(ret); 170 return(ret);
171 } 171 }
172 172
173static int mem_write(BIO *b, char *in, int inl) 173static int mem_write(BIO *b, const char *in, int inl)
174 { 174 {
175 int ret= -1; 175 int ret= -1;
176 int blen; 176 int blen;
@@ -198,7 +198,7 @@ end:
198 return(ret); 198 return(ret);
199 } 199 }
200 200
201static long mem_ctrl(BIO *b, int cmd, long num, char *ptr) 201static long mem_ctrl(BIO *b, int cmd, long num, void *ptr)
202 { 202 {
203 long ret=1; 203 long ret=1;
204 char **pptr; 204 char **pptr;
@@ -208,15 +208,20 @@ static long mem_ctrl(BIO *b, int cmd, long num, char *ptr)
208 switch (cmd) 208 switch (cmd)
209 { 209 {
210 case BIO_CTRL_RESET: 210 case BIO_CTRL_RESET:
211 if (bm->data != NULL) { 211 if (bm->data != NULL)
212 {
212 /* For read only case reset to the start again */ 213 /* For read only case reset to the start again */
213 if(b->flags & BIO_FLAGS_MEM_RDONLY) 214 if(b->flags & BIO_FLAGS_MEM_RDONLY)
214 bm->data -= bm->max - bm->length; 215 {
215 else { 216 bm->data -= bm->max - bm->length;
217 bm->length = bm->max;
218 }
219 else
220 {
216 memset(bm->data,0,bm->max); 221 memset(bm->data,0,bm->max);
217 bm->length=0; 222 bm->length=0;
223 }
218 } 224 }
219 }
220 break; 225 break;
221 case BIO_CTRL_EOF: 226 case BIO_CTRL_EOF:
222 ret=(long)(bm->length == 0); 227 ret=(long)(bm->length == 0);
@@ -300,7 +305,7 @@ static int mem_gets(BIO *bp, char *buf, int size)
300 return(ret); 305 return(ret);
301 } 306 }
302 307
303static int mem_puts(BIO *bp, char *str) 308static int mem_puts(BIO *bp, const char *str)
304 { 309 {
305 int n,ret; 310 int n,ret;
306 311