Fix a SSL reading problem when lines are not CRLF-terminated

Initial
Stephane Bortzmeyer 24 years ago
parent e860fad685
commit fa5e3bb0f1

@ -116,13 +116,22 @@ read_from_server (CHANNEL fs, short ssl)
char reply_code;
int first_line = TRUE;
short body = FALSE;
#ifdef OPENSSL
int sslcode;
#endif
while (!body)
{
if (!ssl)
nr = readline (fs.fs, big_recvline, MAXTOREAD, TRUE);
#ifdef OPENSSL
else
else {
nr = SSL_readline (fs.ssl, big_recvline, MAXTOREAD, TRUE);
if (nr == -1) {
sslcode = ERR_get_error ();
err_ret ("SSL_readline error: %s",
ERR_error_string (sslcode, NULL));
}
}
#endif
/* printf ("DEBUG: reading \"%s\"\n (%d chars)\n", big_recvline, nr); */
/* HTTP replies should be separated by CR-LF. Unfortunately, some

@ -73,6 +73,8 @@ SSL_readline (sslh, ptr, maxlen, ln)
if (buf_end == 0)
{
rc = SSL_read (sslh, SSL_buffer, maxlen);
if (rc == -1)
return rc;
buf_end = rc;
buf_ptr = 0;
}
@ -81,11 +83,19 @@ SSL_readline (sslh, ptr, maxlen, ln)
{
buf_ptr = 0;
rc = SSL_read (sslh, SSL_buffer, maxlen);
if (rc == -1)
return rc;
buf_end = rc;
}
/* Todo: we have a probleme here is the first SSL_read sent back
else if (SSL_buffer[buf_end] != '\n') {
/* We have a probleme here is the first SSL_read sent back
a text not finished by a \n. See www.SSL.de for an
example. */
example. We get more data. See bug #230384 */
rc = SSL_read (sslh, SSL_buffer+buf_end, maxlen);
if (rc == -1)
return rc;
buf_end = buf_end + rc;
}
for (oi = buf_ptr, i = buf_ptr;
i <= buf_end && SSL_buffer[i] != '\n';
i++)
@ -96,6 +106,8 @@ SSL_readline (sslh, ptr, maxlen, ln)
if (SSL_buffer[i] == '\n')
buf_ptr++;
*ptr = '\0';
/* if (ln)
printf ("SSL_redaline returns %d (%s)\n", i - oi, SSL_buffer); */
return (i - oi);
}
else

@ -17,4 +17,9 @@ echo ""
./echoping -C -h / -n 2 www.creditmutuel.fr
echo ""
# bug #230384
./echoping -C -h / -n 2 www.ssl.de

Loading…
Cancel
Save