[ipv6calc] Re: eui64_to_privacy broken for big-endian architectures

Niko Tyni ntyni at iki.fi
Thu Jun 29 20:24:37 CEST 2006


tags 375855 patch
thanks

On Wed, Jun 28, 2006 at 09:27:10PM +0300, Niko Tyni wrote:
> Hi Peter and other ipv6calc list members,
> 
> it looks like the ipv6calc RFC3041 (privacy extensions) code is broken
> on big-endian systems.

OK, the problem is that the _BIG_ENDIAN macro isn't defined in
'sys/types.h' on Linux. It is on Solaris, which is probably
why this hasn't been noticed earlier. The macro is needed
by the md5 code.

I'm attaching a patch that adds the AC_C_BIGENDIAN test to configure.in.
It also makes md5.c include "config.h" for the result. Finally, it makes
the test run in the 'ipv6calc' subdirectory exit with an error code if
there is a failure, so failed tests won't go unnoticed anymore.

Obviously, autoconf and autoheader need to be re-run after this patch
is applied.

I have tested the patch on Debian/x86 and Debian/sparc and on
Solaris/sparc.

Cheers,
-- 
Niko Tyni	ntyni at iki.fi
-------------- next part --------------
--- ipv6calc-0.60.0.orig/md5/Makefile
+++ ipv6calc-0.60.0/md5/Makefile
@@ -6,7 +6,7 @@
 all: md5.o
 
 md5.o: md5.c
-	${CC} ${CFLAGS} -fPIC -o md5.o -c -s md5.c
+	${CC} ${CFLAGS} -I.. -fPIC -o md5.o -c -s md5.c
 
 clean:
 	rm -f *.o *.so.1 *.a
--- ipv6calc-0.60.0.orig/md5/md5.c
+++ ipv6calc-0.60.0/md5/md5.c
@@ -24,6 +24,8 @@
 	for ipv6calc, not needed code was removed
 */
 
+#include "config.h"
+
 #include "md5.h"
 
 #include <sys/types.h>
@@ -31,13 +33,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-/* insert for ipv6calc for proper working on big endian machines */
-#ifdef _BIG_ENDIAN
-#  define WORDS_BIGENDIAN 1
-#endif
-/* end of insert */
-
-
 #ifdef _LIBC
 # include <endian.h>
 # if __BYTE_ORDER == __BIG_ENDIAN
--- ipv6calc-0.60.0.orig/ipv6calc/test_ipv6calc.sh
+++ ipv6calc-0.60.0/ipv6calc/test_ipv6calc.sh
@@ -151,9 +151,11 @@
 	fi
 done
 
-if [ $? -eq 0 ]; then
+retval=$?
+if [ $retval -eq 0 ]; then
 	echo "All tests were successfully done!"
 	exit 0
 else
-	echo $?
+	echo "Tests failed! (code $retval)"
+	exit $retval
 fi
--- ipv6calc-0.60.0.orig/configure.in
+++ ipv6calc-0.60.0/configure.in
@@ -24,6 +24,7 @@
 AC_C_CONST
 AC_TYPE_OFF_T
 AC_TYPE_SIZE_T
+AC_C_BIGENDIAN
 
 dnl Checks for library functions.
 AC_FUNC_MEMCMP


More information about the ipv6calc mailing list