Module Name:    src
Committed By:   christos
Date:           Wed Aug 17 05:30:01 UTC 2011

Modified Files:
        src/crypto/external/bsd/openssl/bin: Makefile
        src/crypto/external/bsd/openssl/dist/apps: s_client.c s_server.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/crypto/external/bsd/openssl/bin/Makefile
cvs rdiff -u -r1.1.1.3 -r1.2 \
    src/crypto/external/bsd/openssl/dist/apps/s_client.c
cvs rdiff -u -r1.1.1.4 -r1.2 \
    src/crypto/external/bsd/openssl/dist/apps/s_server.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/crypto/external/bsd/openssl/bin/Makefile
diff -u src/crypto/external/bsd/openssl/bin/Makefile:1.4 src/crypto/external/bsd/openssl/bin/Makefile:1.5
--- src/crypto/external/bsd/openssl/bin/Makefile:1.4	Tue Jun 21 22:49:42 2011
+++ src/crypto/external/bsd/openssl/bin/Makefile	Wed Aug 17 01:30:01 2011
@@ -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 @@
 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 @@
 .endif
 
 .include <bsd.prog.mk>
-
-# XXX
-.if ${HAVE_GCC} == 45
-COPTS.s_server.c+= -Wno-error
-COPTS.s_client.c+= -Wno-error
-.endif

Index: src/crypto/external/bsd/openssl/dist/apps/s_client.c
diff -u src/crypto/external/bsd/openssl/dist/apps/s_client.c:1.1.1.3 src/crypto/external/bsd/openssl/dist/apps/s_client.c:1.2
--- src/crypto/external/bsd/openssl/dist/apps/s_client.c:1.1.1.3	Sun Jun  5 10:57:10 2011
+++ src/crypto/external/bsd/openssl/dist/apps/s_client.c	Wed Aug 17 01:30:01 2011
@@ -510,6 +510,7 @@
 	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 @@
 		{
 		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 @@
 #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 @@
 			/* 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 @@
 		/* 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 @@
 #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)

Index: src/crypto/external/bsd/openssl/dist/apps/s_server.c
diff -u src/crypto/external/bsd/openssl/dist/apps/s_server.c:1.1.1.4 src/crypto/external/bsd/openssl/dist/apps/s_server.c:1.2
--- src/crypto/external/bsd/openssl/dist/apps/s_server.c:1.1.1.4	Sun Jun  5 10:57:11 2011
+++ src/crypto/external/bsd/openssl/dist/apps/s_server.c	Wed Aug 17 01:30:01 2011
@@ -1857,7 +1857,7 @@
 	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 @@
 
 		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 @@
 			/* 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 @@
 				}
 
 			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))

Reply via email to