提交 aff05428 编写于 作者: D Dr. Stephen Henson

Stop checking for CRLF when start of buffer is reached.

Add rest of long line fix which got missed before
上级 beab098d
...@@ -376,11 +376,12 @@ int SMIME_crlf_copy(BIO *in, BIO *out, int flags) ...@@ -376,11 +376,12 @@ int SMIME_crlf_copy(BIO *in, BIO *out, int flags)
BIO_printf(out, "Content-Type: text/plain\r\n\r\n"); BIO_printf(out, "Content-Type: text/plain\r\n\r\n");
while ((len = BIO_gets(in, linebuf, MAX_SMLEN)) > 0) { while ((len = BIO_gets(in, linebuf, MAX_SMLEN)) > 0) {
eol = 0; eol = 0;
while(iscrlf(linebuf[len - 1])) { while(len && iscrlf(linebuf[len - 1])) {
len--; len--;
eol = 1; eol = 1;
} }
BIO_write(out, linebuf, len); if (len)
BIO_write(out, linebuf, len);
if(eol) BIO_write(out, "\r\n", 2); if(eol) BIO_write(out, "\r\n", 2);
} }
return 1; return 1;
...@@ -423,6 +424,7 @@ static int multi_split(BIO *bio, char *bound, STACK_OF(BIO) **ret) ...@@ -423,6 +424,7 @@ static int multi_split(BIO *bio, char *bound, STACK_OF(BIO) **ret)
{ {
char linebuf[MAX_SMLEN]; char linebuf[MAX_SMLEN];
int len, blen; int len, blen;
int eol = 0, next_eol = 0;
BIO *bpart = NULL; BIO *bpart = NULL;
STACK_OF(BIO) *parts; STACK_OF(BIO) *parts;
char state, part, first; char state, part, first;
...@@ -442,15 +444,21 @@ static int multi_split(BIO *bio, char *bound, STACK_OF(BIO) **ret) ...@@ -442,15 +444,21 @@ static int multi_split(BIO *bio, char *bound, STACK_OF(BIO) **ret)
sk_BIO_push(parts, bpart); sk_BIO_push(parts, bpart);
return 1; return 1;
} else if(part) { } else if(part) {
/* Strip CR+LF from linebuf */
next_eol = 0;
while(len && iscrlf(linebuf[len - 1])) {
next_eol = 1;
len--;
}
if(first) { if(first) {
first = 0; first = 0;
if(bpart) sk_BIO_push(parts, bpart); if(bpart) sk_BIO_push(parts, bpart);
bpart = BIO_new(BIO_s_mem()); bpart = BIO_new(BIO_s_mem());
} else if (eol)
} else BIO_write(bpart, "\r\n", 2); BIO_write(bpart, "\r\n", 2);
/* Strip CR+LF from linebuf */ eol = next_eol;
while(iscrlf(linebuf[len - 1])) len--; if (len)
BIO_write(bpart, linebuf, len); BIO_write(bpart, linebuf, len);
} }
} }
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册