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.
* [including the GNU Public Licence.]
*/
* [including the GNU Public Licence.]
*/
+#ifdef APPS_CRLF
+# include <assert.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
BIO_printf(bio_err," -state - print the 'ssl' states\n");
#ifdef FIONBIO
BIO_printf(bio_err," -nbio - Run with non-blocking IO\n");
BIO_printf(bio_err," -state - print the 'ssl' states\n");
#ifdef FIONBIO
BIO_printf(bio_err," -nbio - Run with non-blocking IO\n");
+#endif
+#ifdef APPS_CRLF
+ BIO_printf(bio_err," -crlf - convert LF from terminal into CRLF\n");
#endif
BIO_printf(bio_err," -quiet - no s_client output\n");
BIO_printf(bio_err," -ssl2 - just use SSLv2\n");
#endif
BIO_printf(bio_err," -quiet - no s_client output\n");
BIO_printf(bio_err," -ssl2 - just use SSLv2\n");
char *cert_file=NULL,*key_file=NULL;
char *CApath=NULL,*CAfile=NULL,*cipher=NULL;
int reconnect=0,badop=0,verify=SSL_VERIFY_NONE,bugs=0;
char *cert_file=NULL,*key_file=NULL;
char *CApath=NULL,*CAfile=NULL,*cipher=NULL;
int reconnect=0,badop=0,verify=SSL_VERIFY_NONE,bugs=0;
+#ifdef APPS_CRLF
+ int crlf=0;
+#endif
int write_tty,read_tty,write_ssl,read_ssl,tty_on,ssl_pending;
SSL_CTX *ctx=NULL;
int ret=1,in_init=1,i,nbio_test=0;
int write_tty,read_tty,write_ssl,read_ssl,tty_on,ssl_pending;
SSL_CTX *ctx=NULL;
int ret=1,in_init=1,i,nbio_test=0;
if (--argc < 1) goto bad;
cert_file= *(++argv);
}
if (--argc < 1) goto bad;
cert_file= *(++argv);
}
+#ifdef APPS_CRLF
+ else if (strcmp(*argv,"-crlf") == 0)
+ crlf=1;
+#endif
else if (strcmp(*argv,"-quiet") == 0)
c_quiet=1;
else if (strcmp(*argv,"-pause") == 0)
else if (strcmp(*argv,"-quiet") == 0)
c_quiet=1;
else if (strcmp(*argv,"-pause") == 0)
#ifndef WINDOWS
else if (FD_ISSET(fileno(stdin),&readfds))
{
#ifndef WINDOWS
else if (FD_ISSET(fileno(stdin),&readfds))
{
- i=read(fileno(stdin),cbuf,BUFSIZZ);
+#ifdef APPS_CRLF
+ if (crlf)
+ {
+ int j, lf_num;
+
+ i=read(fileno(stdin),cbuf,BUFSIZZ/2);
+ lf_num = 0;
+ /* both loops are skipped when i <= 0 */
+ for (j = 0; j < i; j++)
+ if (cbuf[j] == '\n')
+ lf_num++;
+ for (j = i-1; j >= 0; j--)
+ {
+ cbuf[j+lf_num] = cbuf[j];
+ if (cbuf[j] == '\n')
+ {
+ lf_num--;
+ i++;
+ cbuf[j+lf_num] = '\r';
+ }
+ }
+ assert(lf_num == 0);
+ }
+ else
+#endif
+ i=read(fileno(stdin),cbuf,BUFSIZZ);
if ((!c_quiet) && ((i <= 0) || (cbuf[0] == 'Q')))
{
if ((!c_quiet) && ((i <= 0) || (cbuf[0] == 'Q')))
{
* [including the GNU Public Licence.]
*/
* [including the GNU Public Licence.]
*/
+#ifdef APPS_CRLF
+# include <assert.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static int s_nbio=0;
#endif
static int s_nbio_test=0;
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;
static SSL_CTX *ctx=NULL;
static int www=0;
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");
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");
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");
{ hack=1; }
else if (strcmp(*argv,"-state") == 0)
{ state=1; }
{ 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)
else if (strcmp(*argv,"-quiet") == 0)
{ s_quiet=1; }
else if (strcmp(*argv,"-bugs") == 0)
if (i <= 0) continue;
if (FD_ISSET(fileno(stdin),&readfds))
{
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'))
if (!s_quiet)
{
if ((i <= 0) || (buf[0] == 'Q'))