Hi, FYI, I committed the patch below to both branches. It fixes a bus error (unaligned access) on SPARC in the `AF_INET' case.
Thanks, Ludovic.
--- orig/libguile/ChangeLog +++ mod/libguile/ChangeLog @@ -1,3 +1,9 @@ +2007-06-12 Ludovic Courtès <[EMAIL PROTECTED]> + + * socket.c (scm_inet_ntop): In the `AF_INET' case, declare `addr4' + as an `scm_t_uint32' rather than re-using `addr6'. This fixes a + bus error on SPARC (and possibly others) due to unaligned access. + 2007-06-07 Ludovic Courtès <[EMAIL PROTECTED]> * posix.c (scm_ttyname): Check whether RESULT is NULL before --- orig/libguile/socket.c +++ mod/libguile/socket.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996,1997,1998,2000,2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1996,1997,1998,2000,2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -386,16 +386,28 @@ SCM_DEFINE (scm_inet_ntop, "inet-ntop", #else char dst[46]; #endif - char addr6[16]; + const char *result; af = scm_to_int (family); SCM_ASSERT_RANGE (1, family, af == AF_INET || af == AF_INET6); if (af == AF_INET) - *(scm_t_uint32 *) addr6 = htonl (SCM_NUM2ULONG (2, address)); + { + scm_t_uint32 addr4; + + addr4 = htonl (SCM_NUM2ULONG (2, address)); + result = inet_ntop (af, &addr4, dst, sizeof (dst)); + } else - scm_to_ipv6 ((scm_t_uint8 *) addr6, address); - if (inet_ntop (af, &addr6, dst, sizeof dst) == NULL) + { + char addr6[16]; + + scm_to_ipv6 ((scm_t_uint8 *) addr6, address); + result = inet_ntop (af, &addr6, dst, sizeof (dst)); + } + + if (result == NULL) SCM_SYSERROR; + return scm_from_locale_string (dst); } #undef FUNC_NAME --- orig/test-suite/ChangeLog +++ mod/test-suite/ChangeLog @@ -1,3 +1,8 @@ +2007-06-12 Ludovic Courtès <[EMAIL PROTECTED]> + + * tests/socket.test: Renamed module to `(test-suite test-socket)'. + (inet-ntop): New test prefix. + 2007-06-07 Ludovic Courtès <[EMAIL PROTECTED]> * lib.scm (exception:system-error): New variable. --- orig/test-suite/tests/socket.test +++ mod/test-suite/tests/socket.test @@ -1,6 +1,6 @@ ;;;; socket.test --- test socket functions -*- scheme -*- ;;;; -;;;; Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. +;;;; Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -16,7 +16,7 @@ ;;;; License along with this library; if not, write to the Free Software ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -(define-module (test-suite test-numbers) +(define-module (test-suite test-socket) #:use-module (test-suite lib)) @@ -101,6 +101,22 @@ (inet-pton AF_INET6 "0000:0000:0000:0000:0000:0000:0000:00F0")))))) +(if (defined? 'inet-ntop) + (with-test-prefix "inet-ntop" + + (with-test-prefix "ipv4" + (pass-if "127.0.0.1" + (equal? "127.0.0.1" (inet-ntop AF_INET INADDR_LOOPBACK)))) + + (if (defined? 'AF_INET6) + (with-test-prefix "ipv6" + (pass-if "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF" + (string-ci=? "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF" + (inet-ntop AF_INET6 (- (expt 2 128) 1)))) + + (pass-if "::1" + (equal? "::1" (inet-ntop AF_INET6 1))))))) + ;;; ;;; make-socket-address
_______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel