aboutsummaryrefslogtreecommitdiffstats
path: root/apps/s_server.c
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>1999-08-07 02:51:10 +0000
committerBodo Möller <bodo@openssl.org>1999-08-07 02:51:10 +0000
commit1bdb8633c105e11708ec79034eb1f0531799d3fa (patch)
tree2334a50a7c00d75c12e9c9560727f12fa10d4f6c /apps/s_server.c
parentc97cbcb35bb5e29b896efbbc1d73fc62db40522e (diff)
downloadopenssl-1bdb8633c105e11708ec79034eb1f0531799d3fa.tar.gz
New option "-crlf" to s_client and s_server which tells them to convert
LFs into CRLFs when forwarding data from stdin to the TLS connection. This is necessary for properly talking HTTP. Because of the code freeze this change is by default disabled for now; without -DAPPS_CRLF, the code is exactly as before.
Diffstat (limited to 'apps/s_server.c')
-rw-r--r--apps/s_server.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/apps/s_server.c b/apps/s_server.c
index 54989316f8..a78a4bcd7b 100644
--- a/apps/s_server.c
+++ b/apps/s_server.c
@@ -56,6 +56,9 @@
* [including the GNU Public Licence.]
*/
+#ifdef APPS_CRLF
+# include <assert.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -166,6 +169,9 @@ static char *s_dcert_file=NULL,*s_dkey_file=NULL;
static int s_nbio=0;
#endif
static int s_nbio_test=0;
+#ifdef APPS_CRLF
+ int s_crlf=0;
+#endif
static SSL_CTX *ctx=NULL;
static int www=0;
@@ -213,6 +219,9 @@ static void sv_usage(void)
BIO_printf(bio_err," -nbio - Run with non-blocking IO\n");
#endif
BIO_printf(bio_err," -nbio_test - test with the non-blocking test bio\n");
+#ifdef APPS_CRLF
+ BIO_printf(bio_err," -crlf - convert LF from terminal into CRLF\n");
+#endif
BIO_printf(bio_err," -debug - Print more output\n");
BIO_printf(bio_err," -state - Print the SSL states\n");
BIO_printf(bio_err," -CApath arg - PEM format directory of CA's\n");
@@ -516,6 +525,10 @@ int MAIN(int argc, char *argv[])
{ hack=1; }
else if (strcmp(*argv,"-state") == 0)
{ state=1; }
+#ifdef APPS_CRLF
+ else if (strcmp(*argv,"-crlf") == 0)
+ { s_crlf=1; }
+#endif
else if (strcmp(*argv,"-quiet") == 0)
{ s_quiet=1; }
else if (strcmp(*argv,"-bugs") == 0)
@@ -800,7 +813,32 @@ static int sv_body(char *hostname, int s, unsigned char *context)
if (i <= 0) continue;
if (FD_ISSET(fileno(stdin),&readfds))
{
- i=read(fileno(stdin),buf,bufsize);
+#ifdef APPS_CRLF
+ if (s_crlf)
+ {
+ int j, lf_num;
+
+ i=read(fileno(stdin), buf, bufsize/2);
+ lf_num = 0;
+ /* both loops are skipped when i <= 0 */
+ for (j = 0; j < i; j++)
+ if (buf[j] == '\n')
+ lf_num++;
+ for (j = i-1; j >= 0; j--)
+ {
+ buf[j+lf_num] = buf[j];
+ if (buf[j] == '\n')
+ {
+ lf_num--;
+ i++;
+ buf[j+lf_num] = '\r';
+ }
+ }
+ assert(lf_num == 0);
+ }
+ else
+#endif
+ i=read(fileno(stdin),buf,bufsize);
if (!s_quiet)
{
if ((i <= 0) || (buf[0] == 'Q'))