summaryrefslogtreecommitdiffstats
path: root/crypto/bio/bss_mem.c
diff options
context:
space:
mode:
authorsimon <simon@FreeBSD.org>2009-06-07 19:56:18 +0000
committersimon <simon@FreeBSD.org>2009-06-07 19:56:18 +0000
commitfc5b6d55de4ea73602809deec0b965745f83a804 (patch)
tree873f9f63931a5d069bbcb053ea49eec4a92802dc /crypto/bio/bss_mem.c
parent212fba63d3a2fed2e6ca619035a42526db27a3b8 (diff)
downloadFreeBSD-src-fc5b6d55de4ea73602809deec0b965745f83a804.zip
FreeBSD-src-fc5b6d55de4ea73602809deec0b965745f83a804.tar.gz
Import OpenSSL 0.9.8k.
Diffstat (limited to 'crypto/bio/bss_mem.c')
-rw-r--r--crypto/bio/bss_mem.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/crypto/bio/bss_mem.c b/crypto/bio/bss_mem.c
index a4edb71..e7ab9cb 100644
--- a/crypto/bio/bss_mem.c
+++ b/crypto/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;
OpenPOWER on IntegriCloud