[clisp/f16] Add hostname patch to fix some illegal code, which led to a failing test. The original code allocate

Jerry James jjames at fedoraproject.org
Thu Jan 12 20:35:14 UTC 2012


commit 3444c42f8c6daa5e63b747433e6af506c2657b6b
Author: Jerry James <loganjerry at gmail.com>
Date:   Thu Jan 12 13:33:24 2012 -0700

    Add hostname patch to fix some illegal code, which led to a failing test.
    The original code allocates an array of characters on the stack inside an inner
    block, then keeps a pointer to the array that lives beyond the lifetime of the
    inner block.  Later accesses to the array via the pointer see junk bytes.

 clisp-hostname.patch |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++
 clisp.spec           |   13 +++++++--
 2 files changed, 84 insertions(+), 3 deletions(-)
---
diff --git a/clisp-hostname.patch b/clisp-hostname.patch
new file mode 100644
index 0000000..59dbf89
--- /dev/null
+++ b/clisp-hostname.patch
@@ -0,0 +1,74 @@
+--- src/socket.d.orig	2009-10-08 08:45:13.000000000 -0600
++++ src/socket.d	2012-01-12 11:22:24.701723636 -0700
+@@ -57,8 +57,8 @@
+ /* ============ hostnames and IP addresses only (no sockets) ============
+ 
+  Fetches the machine's host name.
+- get_hostname(host =);
+- The name is allocated on the stack, with dynamic extent.
++ get_hostname(hostname);
++ where hostname is an array of MAXHOSTNAMELEN+1 characters.
+  < const char* host: The host name.
+  (Note: In some cases we could get away with less system calls by simply
+  setting
+@@ -67,13 +67,12 @@
+  sds: never: you will always get localhost/127.0.0.1 - what's the point? */
+ #if defined(HAVE_GETHOSTNAME)
+ /* present on all supported unix systems and on woe32 */
+-  #define get_hostname(host_assignment)                                 \
+-    do {  var char hostname[MAXHOSTNAMELEN+1];                          \
++  #define get_hostname(hostname)                                        \
++    do {                                                                \
+       begin_system_call();                                              \
+       if ( gethostname(&hostname[0],MAXHOSTNAMELEN) <0) { SOCK_error(); } \
+       end_system_call();                                                \
+       hostname[MAXHOSTNAMELEN] = '\0';                                  \
+-      host_assignment &hostname[0];                                     \
+     } while(0)
+ #else
+   #error get_hostname is not defined
+@@ -207,8 +206,8 @@ LISPFUNN(machine_instance,0)
+          (if (or (null address) (zerop (length address)))
+            hostname
+            (apply #'string-concat hostname " [" (inet-ntop address) "]"))) */
+-    var const char* host;
+-    get_hostname(host =);
++    var char host[MAXHOSTNAMELEN+1];
++    get_hostname(host);
+     result = asciz_to_string(host,O(misc_encoding)); /* hostname as result */
+    #ifdef HAVE_GETHOSTBYNAME
+     pushSTACK(result); /* hostname as 1st string */
+@@ -389,8 +388,8 @@ local int resolve_host1 (const void* add
+ modexp struct hostent* resolve_host (object arg) {
+   var struct hostent* he;
+   if (eq(arg,S(Kdefault))) {
+-    var char* host;
+-    get_hostname(host =);
++    var char host[MAXHOSTNAMELEN+1];
++    get_hostname(host);
+     begin_system_call();
+     he = gethostbyname(host);
+     end_system_call();
+@@ -724,8 +723,9 @@ global SOCKET connect_to_x_server (const
+     if (conntype == conn_tcp) {
+       var unsigned short port = X_TCP_PORT+display;
+       if (host[0] == '\0') {
+-        get_hostname(host =);
+-        fd = with_host_port(host,port,&connect_to_x_via_ip,NULL);
++        var char hostname[MAXHOSTNAMELEN+1];
++        get_hostname(hostname);
++        fd = with_host_port(hostname,port,&connect_to_x_via_ip,NULL);
+       } else {
+         fd = with_host_port(host,port,&connect_to_x_via_ip,NULL);
+       }
+@@ -798,8 +798,8 @@ global host_data_t * socket_getlocalname
+   if (socket_getlocalname_aux(socket_handle,hd) == NULL)
+     return NULL;
+   if (resolve_p) { /* Fill in hd->truename. */
+-    var const char* host;
+-    get_hostname(host =); /* was: host = "localhost"; */
++    var char host[MAXHOSTNAMELEN+1];
++    get_hostname(host); /* was: host = "localhost"; */
+     ASSERT(strlen(host) <= MAXHOSTNAMELEN);
+     strcpy(hd->truename,host);
+   } else {
diff --git a/clisp.spec b/clisp.spec
index 1bf1c65..2d0563a 100644
--- a/clisp.spec
+++ b/clisp.spec
@@ -1,14 +1,16 @@
 Name:		clisp
 Summary:	ANSI Common Lisp implementation
 Version:	2.49
-Release:	4%{?dist}
+Release:	5%{?dist}
 
 Group:		Development/Languages
 License:	GPLv2
-URL:		http://clisp.cons.org
+URL:		http://www.clisp.org/
 Source0:	http://downloads.sourceforge.net/clisp/clisp-%{version}.tar.bz2
 # Adapt to libsvm 3.1.  Sent upstream 23 Jun 2011.
 Patch0:		clisp-libsvm.patch
+# Fix an illegal C construct that allows GCC 4.7 to produce bad code.
+Patch1:		clisp-hostname.patch
 BuildRequires:	compat-readline5-devel
 BuildRequires:	db4-devel
 BuildRequires:	dbus-devel
@@ -67,7 +69,7 @@ Maxima, ACL2 and many other Common Lisp packages.
 Summary:	Development files for CLISP
 Group:		Development/Languages
 Provides:	%{name}-static = %{version}-%{release} 
-Requires:	%{name} = %{version}-%{release}, automake
+Requires:	%{name}%{?_isa} = %{version}-%{release}, automake
 
 %description devel
 Files necessary for linking CLISP programs.
@@ -76,6 +78,7 @@ Files necessary for linking CLISP programs.
 %prep
 %setup -q
 %patch0
+%patch1
 
 # Convince CLisp to build against compat-readline5 instead of readline.
 # This is to avoid pulling the GPLv3 readline 6 into a GPLv2 CLisp binary.
@@ -192,6 +195,10 @@ chmod a+x \
 
 
 %changelog
+* Sun Jan  8 2012 Jerry James <loganjerry at gmail.com> - 2.49-5
+- Rebuild for GCC 4.7
+- Minor spec file cleanups
+
 * Thu Jun 23 2011 Jerry James <loganjerry at gmail.com> - 2.49-4
 - Add libsvm patch to fix FTBFS on Rawhide (bz 715970)
 - Fix readline module to also use compat-readline5 instead of readline6


More information about the scm-commits mailing list