[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Fix for Zope segfault on amd64



*** Regarding Re: Fix for Zope segfault on amd64; Goswin von Brederlow
    <brederlo@informatik.uni-tuebingen.de> adds:

Goswin> Shouldn't that bug appear on all 64bit architectures and the
Goswin> patch work on every architecture, even 32bit. Int is 32bit on
Goswin> all debian archs while long varies.

Agreed.  Since I only have access to i386 and amd64 I went for the
conservative approach.  However, I think there is a better way to fix
the bug that should be more general and avoids the #ifdef:

--- /tmp/Zope-2.6.4-src/lib/Components/initgroups/initgroups.c  2002-07-25 17:54:02.000000000 -0400
+++ lib/Components/initgroups/initgroups.c      2005-01-22 09:41:56.882300943 -0500
@@ -23,12 +23,15 @@
 initgroups_initgroups(PyObject *self, PyObject *args)
 {
        char *username;
-       gid_t gid;
+       long gid;
 
+       /* Use a long to get the gid rather than gid_t to avoid
+          dependencies on 32-bit versus 64-bit architectures,
+          etc.  */
        if (!PyArg_ParseTuple(args, "sl:initgroups", &username, &gid))
                return NULL;
 
-       if (initgroups(username, gid) == -1)
+       if (initgroups(username, (gid_t) gid) == -1)
                return PyErr_SetFromErrno(PyExc_OSError);
 
        Py_INCREF(Py_None);

This should work on most common architectures, would you agree?

Per

-- 
Per Bojsen                                              <per.bojsen@comcast.net>
7 Francis Road
Billerica, MA 01821-3618
USA



Reply to: