remove gcc-4.5 hacks; gcc-4.5 does not like fileno() to be unchecked, and

produces an unhelpful out of bounds array warning, so check it.
This commit is contained in:
christos 2011-08-17 05:30:01 +00:00
parent 70183e515a
commit 5573cb4a88
3 changed files with 35 additions and 22 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.4 2011/06/22 02:49:42 mrg Exp $
# $NetBSD: Makefile,v 1.5 2011/08/17 05:30:01 christos Exp $
WARNS?= 2 # XXX -Wcast-qual
@ -10,7 +10,7 @@ BINDIR=/usr/bin
USE_FORT?= yes # cryptographic software
# RCSid:
# $Id: Makefile,v 1.4 2011/06/22 02:49:42 mrg Exp $
# $Id: Makefile,v 1.5 2011/08/17 05:30:01 christos Exp $
#
# @(#) Copyright (c) 1995 Simon J. Gerraty
#
@ -112,9 +112,3 @@ FILESDIR=/usr/share/examples/openssl
.endif
.include <bsd.prog.mk>
# XXX
.if ${HAVE_GCC} == 45
COPTS.s_server.c+= -Wno-error
COPTS.s_client.c+= -Wno-error
.endif

View File

@ -510,6 +510,7 @@ int MAIN(int argc, char **argv)
int cbuf_len,cbuf_off;
int sbuf_len,sbuf_off;
fd_set readfds,writefds;
int fdin, fdout;
short port=PORT;
int full_log=1;
char *host=SSL_HOST_NAME;
@ -1402,6 +1403,18 @@ SSL_set_tlsext_status_ids(con, ids);
{
FD_ZERO(&readfds);
FD_ZERO(&writefds);
fdin = fileno(stdin);
if (fdin < 0)
{
BIO_printf(bio_err,"bad fileno for stdin\n");
goto shut;
}
fdout = fileno(stdout);
if (fdout < 0)
{
BIO_printf(bio_err,"bad fileno for stdout\n");
goto shut;
}
if ((SSL_version(con) == DTLS1_VERSION) &&
DTLSv1_get_timeout(con, &timeout))
@ -1468,8 +1481,8 @@ SSL_set_tlsext_status_ids(con, ids);
#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_NETWARE) && !defined (OPENSSL_SYS_BEOS_R5)
if (tty_on)
{
if (read_tty) openssl_fdset(fileno(stdin),&readfds);
if (write_tty) openssl_fdset(fileno(stdout),&writefds);
if (read_tty) openssl_fdset(fdin,&readfds);
if (write_tty) openssl_fdset(fdout,&writefds);
}
if (read_ssl)
openssl_fdset(SSL_get_fd(con),&readfds);
@ -1529,21 +1542,21 @@ SSL_set_tlsext_status_ids(con, ids);
/* Under BeOS-R5 the situation is similar to DOS */
i=0;
stdin_set = 0;
(void)fcntl(fileno(stdin), F_SETFL, O_NONBLOCK);
(void)fcntl(fdin, F_SETFL, O_NONBLOCK);
if(!write_tty) {
if(read_tty) {
tv.tv_sec = 1;
tv.tv_usec = 0;
i=select(width,(void *)&readfds,(void *)&writefds,
NULL,&tv);
if (read(fileno(stdin), sbuf, 0) >= 0)
if (read(fdin, sbuf, 0) >= 0)
stdin_set = 1;
if (!i && (stdin_set != 1 || !read_tty))
continue;
} else i=select(width,(void *)&readfds,(void *)&writefds,
NULL,timeoutp);
}
(void)fcntl(fileno(stdin), F_SETFL, 0);
(void)fcntl(fdin, F_SETFL, 0);
#else
i=select(width,(void *)&readfds,(void *)&writefds,
NULL,timeoutp);
@ -1634,7 +1647,7 @@ SSL_set_tlsext_status_ids(con, ids);
/* Assume Windows/DOS/BeOS can always write */
else if (!ssl_pending && write_tty)
#else
else if (!ssl_pending && FD_ISSET(fileno(stdout),&writefds))
else if (!ssl_pending && FD_ISSET(fdout,&writefds))
#endif
{
#ifdef CHARSET_EBCDIC
@ -1725,7 +1738,7 @@ printf("read=%d pending=%d peek=%d\n",k,SSL_pending(con),SSL_peek(con,zbuf,10240
#elif defined(OPENSSL_SYS_BEOS_R5)
else if (stdin_set)
#else
else if (FD_ISSET(fileno(stdin),&readfds))
else if (FD_ISSET(fdin,&readfds))
#endif
{
if (crlf)

View File

@ -1857,7 +1857,7 @@ static int sv_body(char *hostname, int s, unsigned char *context)
char *buf=NULL;
fd_set readfds;
int ret=1,width;
int k,i;
int k,i, fdin;
unsigned long l;
SSL *con=NULL;
BIO *sbio;
@ -1999,9 +1999,15 @@ static int sv_body(char *hostname, int s, unsigned char *context)
if (!read_from_sslcon)
{
fdin = fileno(stdin);
if (fdin < 0)
{
BIO_printf(bio_err,"Bad fileno for stdin\n");
goto err;
}
FD_ZERO(&readfds);
#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_NETWARE) && !defined(OPENSSL_SYS_BEOS_R5)
openssl_fdset(fileno(stdin),&readfds);
openssl_fdset(fdin,&readfds);
#endif
openssl_fdset(s,&readfds);
/* Note: under VMS with SOCKETSHR the second parameter is
@ -2026,13 +2032,13 @@ static int sv_body(char *hostname, int s, unsigned char *context)
/* Under BeOS-R5 the situation is similar to DOS */
tv.tv_sec = 1;
tv.tv_usec = 0;
(void)fcntl(fileno(stdin), F_SETFL, O_NONBLOCK);
(void)fcntl(fdin, F_SETFL, O_NONBLOCK);
i=select(width,(void *)&readfds,NULL,NULL,&tv);
if ((i < 0) || (!i && read(fileno(stdin), buf, 0) < 0))
if ((i < 0) || (!i && read(fdin, buf, 0) < 0))
continue;
if (read(fileno(stdin), buf, 0) >= 0)
if (read(fdin, buf, 0) >= 0)
read_from_terminal = 1;
(void)fcntl(fileno(stdin), F_SETFL, 0);
(void)fcntl(fdin, F_SETFL, 0);
#else
if ((SSL_version(con) == DTLS1_VERSION) &&
DTLSv1_get_timeout(con, &timeout))
@ -2048,7 +2054,7 @@ static int sv_body(char *hostname, int s, unsigned char *context)
}
if (i <= 0) continue;
if (FD_ISSET(fileno(stdin),&readfds))
if (FD_ISSET(fdin,&readfds))
read_from_terminal = 1;
#endif
if (FD_ISSET(s,&readfds))