Re: suspicious VxWorks patch

2003-09-29 Thread Bob Bradley
On 9/29/03 7:29 AM, Gisle Vanem [EMAIL PROTECTED] wrote:

 #define ioctlsocket(a,b,c)  ioctl((a),(b),*(int*)(c))
 
 Can this really be right? I mean using it in BIO_socket_ioctl()
 expands to:
 ioctlsocket (fd, type, *(int*)ptr);
 
 I would assume VxWorks to expect a pointer in the 3rd arg
 to it's ioctl(). If so, the above could crash or at worst silently
 trash some unrelated data.

I submitted a patch to cast it to an int instead of dereferencing it.
VxWorks ioctl takes an int for the 3 parameter, but it is treated similarly
to how other platforms treat the 3 parameter to ioctl (sometimes a pointer).
The original code for VxWorks in e_os.h was this (note the dereference of
c):

#define ioctlsocket(a,b,c)  ioctl((a),(b),*(c))

This did not compile because c is sometimes a void *. I changed it to the
following, which has difference semantics than the original (no longer
dereferences), but I think is correct for VxWorks (assumes an int is big
enough to hold a pointer, which is not always true on all platforms, but
this is a limitation of the VxWorks ioctl because it uses an int for that
parameter):

#define ioctlsocket(a,b,c)  ioctl((a),(b),(int)(c))

The latest version of e_os.h has the change.

__
OpenSSL Project http://www.openssl.org
Development Mailing List   [EMAIL PROTECTED]
Automated List Manager   [EMAIL PROTECTED]


[PATCH] VxWorks for MIPS, etc.

2003-09-28 Thread Bob Bradley
The attached patch includes VxWorks improvements (MIPS support and other
additions) detailed below. The patch was diff'd against
openssl-0.9.7-stable-SNAP-20030928.tar.gz, which I thought was the same as
the OpenSSL_0_9_7-stable branch (at the time).

Added support for building OpenSSL for VxWorks for MIPS32 little endian
(only MIPS platform I am able to try, but I suspect big endian would just
need the endian flags set to BE/MIPSBE). Added -nostdinc to the
vxworks-ppc860 Configure line (I am not able to test the other
configurations so I didn't touch them) to avoid problems picking up system
headers instead of the VxWorks versions if you have both installed.

Added VxWorks section to e_os.h for socket-related macros to override the
defaults: Change writesocket to cast the buffer parameter to char * to avoid
const char * - char * warnings due to VxWorks headers prototyping write to
take a char * (write doesn't modify the buffer).

Changed the ioctlsocket macro to cast its argument to an int instead of
dereferencing it. My previous patch fixed compilation problems, but kept the
same semantics (dereferencing). This patch changes the semantics, but I
think it is more correct because the original implementation made it
difficult to use value-result parameters (e.g. FIONREAD, which takes an int
* so you had to pass ioctlsocket an int ** for it work, unlike other
platforms). This change basically makes ioctlsocket for VxWorks work like
all other platforms. If people were using ioctlsocket on VxWorks with
arguments and relying on the dereference, they will need to change to not
doubly take the address after this patch. I suspect people are not using it
in this manner because the original version would not compile in that case.
Please let me know if you feel I am incorrect about this.

diff -ur openssl-orig/Configure openssl-work/Configure
--- openssl-orig/Configure	2003-09-27 01:01:28.0 -0700
+++ openssl-work/Configure	2003-09-28 06:12:02.0 -0700
@@ -560,7 +560,8 @@
 "vxworks-ppc405","ccppc:-g -msoft-float -mlongcall -DCPU=PPC405 -I\$(WIND_BASE)/target/h:::VXWORKS:-r:",
 "vxworks-ppc750","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h \$(DEBUG_FLAG):::VXWORKS:-r:",
 "vxworks-ppc750-debug","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DDEBUG -g:::VXWORKS:-r:",
-"vxworks-ppc860","ccppc:-g -msoft-float -DCPU=PPC860 -DNO_STRINGS_H -I\$(WIND_BASE)/target/h:::VXWORKS:-r:",
+"vxworks-ppc860","ccppc:-nostdinc -msoft-float -DCPU=PPC860 -DNO_STRINGS_H -I\$(WIND_BASE)/target/h:::VXWORKS:-r:",
+"vxworks-mipsle","ccmips:-B\$(WIND_BASE)/host/\$(WIND_HOST_TYPE)/lib/gcc-lib/ -DL_ENDIAN -EL -Wl,-EL -mips2 -mno-branch-likely -G 0 -fno-builtin -msoft-float -DCPU=MIPS32 -DMIPSEL -DNO_STRINGS_H -I\$(WIND_BASE)/target/h:::VXWORKS:-rranlibmips:",
 
 # Compaq Non-Stop Kernel (Tandem)
 "tandem-c89","c89:-Ww -D__TANDEM -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1 -D_TANDEM_SOURCE -DB_ENDIAN::(unknown):::THIRTY_TWO_BIT:::",
diff -ur openssl-orig/e_os.h openssl-work/e_os.h
--- openssl-orig/e_os.h	2003-09-27 01:01:28.0 -0700
+++ openssl-work/e_os.h	2003-09-28 06:12:54.0 -0700
@@ -174,6 +174,13 @@
 #define closesocket(s)  close(s)
 #define readsocket(s,b,n)   recv((s),(b),(n),0)
 #define writesocket(s,b,n)  send((s),(b),(n),0)
+#elif defined(OPENSSL_SYS_VXWORKS)
+#define get_last_socket_error()	errno
+#define clear_socket_error()	errno=0
+#define ioctlsocket(a,b,c)	ioctl((a),(b),(int)(c))
+#define closesocket(s)		close(s)
+#define readsocket(s,b,n)	read((s),(b),(n))
+#define writesocket(s,b,n)	write((s),(char *)(b),(n))
 #else
 #define get_last_socket_error()	errno
 #define clear_socket_error()	errno=0
@@ -519,10 +526,6 @@
 #define TTY_STRUCT int
 
 #define sleep(a) taskDelay((a) * sysClkRateGet())
-#if defined(ioctlsocket)
-#undef ioctlsocket
-#endif
-#define ioctlsocket(a,b,c)  ioctl((a),(b),*(int*)(c))
 
 #include 
 #include 


[PATCH] VxWorks PowerPC 860 and no-md2

2003-09-27 Thread Bob Bradley
The attached patch adds Configure script support for VxWorks for PowerPC
860, fixes a compile problem with VxWorks builds, and fixes build problems
with no-md2.

diff -ur openssl-orig/Configure openssl-work/Configure
--- openssl-orig/Configure	2003-04-09 22:46:55.0 -0700
+++ openssl-work/Configure	2003-09-26 23:11:36.0 -0700
@@ -560,6 +560,7 @@
 "vxworks-ppc405","ccppc:-g -msoft-float -mlongcall -DCPU=PPC405 -I\$(WIND_BASE)/target/h:::VXWORKS:-r:",
 "vxworks-ppc750","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h \$(DEBUG_FLAG):::VXWORKS:-r:",
 "vxworks-ppc750-debug","ccppc:-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DDEBUG -g:::VXWORKS:-r:",
+"vxworks-ppc860","ccppc:-g -msoft-float -DCPU=PPC860 -DNO_STRINGS_H -I\$(WIND_BASE)/target/h:::VXWORKS:-r:",
 
 # Compaq Non-Stop Kernel (Tandem)
 "tandem-c89","c89:-Ww -D__TANDEM -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1 -D_TANDEM_SOURCE -DB_ENDIAN::(unknown):::THIRTY_TWO_BIT:::",
diff -ur openssl-orig/crypto/md2/md2test.c openssl-work/crypto/md2/md2test.c
--- openssl-orig/crypto/md2/md2test.c	2003-02-19 03:22:18.0 -0800
+++ openssl-work/crypto/md2/md2test.c	2003-09-26 23:12:02.0 -0700
@@ -59,7 +59,9 @@
 #include 
 #include 
 #include 
+#ifndef OPENSSL_NO_MD2
 #include 
+#endif
 
 #include "../e_os.h"
 
diff -ur openssl-orig/e_os.h openssl-work/e_os.h
--- openssl-orig/e_os.h	2002-12-04 01:54:22.0 -0800
+++ openssl-work/e_os.h	2003-09-26 23:12:14.0 -0700
@@ -520,7 +520,7 @@
 #if defined(ioctlsocket)
 #undef ioctlsocket
 #endif
-#define ioctlsocket(a,b,c) ioctl((a),(b),*(c))
+#define ioctlsocket(a,b,c)  ioctl((a),(b),*(int*)(c))
 
 #include 
 #include 
diff -ur openssl-orig/test/md2test.c openssl-work/test/md2test.c
--- openssl-orig/test/md2test.c	2003-02-19 03:22:18.0 -0800
+++ openssl-work/test/md2test.c	2003-09-26 23:12:20.0 -0700
@@ -59,7 +59,9 @@
 #include 
 #include 
 #include 
+#ifndef OPENSSL_NO_MD2
 #include 
+#endif
 
 #include "../e_os.h"