summaryrefslogtreecommitdiff
path: root/lib/libcrypto/bio/bss_mem.c
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2009-04-06 06:33:21 +0000
committerDamien Miller <djm@cvs.openbsd.org>2009-04-06 06:33:21 +0000
commit4af955ab47cb58f0856af2543cfd369ca621acf4 (patch)
tree2a9f13536ecfa4cb24b1f0b68532d101a9c44ef6 /lib/libcrypto/bio/bss_mem.c
parentcea69e0d929b3248b3139c9ca312f9c85933095f (diff)
resolve conflicts
Diffstat (limited to 'lib/libcrypto/bio/bss_mem.c')
-rw-r--r--lib/libcrypto/bio/bss_mem.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/libcrypto/bio/bss_mem.c b/lib/libcrypto/bio/bss_mem.c
index a4edb711aec..e7ab9cb3a3f 100644
--- a/lib/libcrypto/bio/bss_mem.c
+++ b/lib/libcrypto/bio/bss_mem.c
@@ -284,6 +284,7 @@ static int mem_gets(BIO *bp, char *buf, int size)
BIO_clear_retry_flags(bp);
j=bm->length;
+ if ((size-1) < j) j=size-1;
if (j <= 0)
{
*buf='\0';
@@ -292,17 +293,18 @@ static int mem_gets(BIO *bp, char *buf, int size)
p=bm->data;
for (i=0; i<j; i++)
{
- if (p[i] == '\n') break;
- }
- if (i == j)
- {
- BIO_set_retry_read(bp);
- /* return(-1); change the semantics 0.6.6a */
+ if (p[i] == '\n')
+ {
+ i++;
+ break;
+ }
}
- else
- i++;
- /* i is the max to copy */
- if ((size-1) < i) i=size-1;
+
+ /*
+ * i is now the max num of bytes to copy, either j or up to
+ * and including the first newline
+ */
+
i=mem_read(bp,buf,i);
if (i > 0) buf[i]='\0';
ret=i;