[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; Vincent Hanquez
    <tab@snarc.org> adds:

Vincent> This is wrong. gid_t is 32 bits on all architectures.

This may be true for Linux but I wouldn't be so certain this is true
for all platforms Zope runs on.

Vincent> You should use "si:initgroups" everytime and certainly not
Vincent> change the gid type to a long.

You're making the assumption that an int is 32-bit or at least large
enough to contain gid_t on all platforms supported by Zope.  It is
better to use a long since it is extremely unlikely that gid_t is a
`bigger' integer type than long on any of the platforms out there.

Changing the type of gid to long ensures that the PyArg_ParseTuple()
call is safe.  Casting the value returned to gid_t might mask the case
where the value passed from the Python script is out of range of the
values representable in a gid_t, but at least that doesn't cause the
code to segfault.  One could argue that some error checking code
should be added that would take care of out-of-range type errors,
though.

Per

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



Reply to: