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

Re: Bug#279323: Fix for Zope segfault on amd64



*** Regarding Re: Bug#279323: Fix for Zope segfault on amd64;
    debdev@tonelli.sns.it (A Mennucc) adds:

A> Does zope2.7 segfauls as well?

I don't know, I haven't tried it.

A> In zope2.7 the line is

A>  if (!PyArg_ParseTuple(args, "sI:initgroups", &username, &igid))

The complete function is:

  static PyObject *
  initgroups_initgroups(PyObject *self, PyObject *args)
  {
  	char *username;
  	unsigned int igid;
  	gid_t gid;
  
  	if (!PyArg_ParseTuple(args, "sI:initgroups", &username, &igid))
  		return NULL;
  
  	gid = igid;
  
  	if (initgroups(username, gid) == -1)
  		return PyErr_SetFromErrno(PyExc_OSError);
  
  	Py_INCREF(Py_None);
  	return Py_None;
  }

They actually chose to fix the segfault in a manner similar to what
I've been suggesting except they chose to parse the integer that will
become the gid as an unsigned int instead of a long.  And they
introcuded the temporary variable igid to hold the parsed unsinged int
value.  No, this code will not segfault as they avoid passing a
pointer to gid_t to the PyArg_ParseTuple() function.

A> I also found this bit from the 'info libc6'=20
A>    With the `-Wformat' option, the GNU C compiler checks calls to
A> `scanf' and related functions.  It examines the format string and
A> verifies that the correct number and types of arguments are supplied.
A> There is also a GNU C syntax to tell the compiler that a function you
A> write uses a `scanf'-style format string.  *Note Declaring Attributes
A> of Functions: (gcc.info)Function Attributes, for more information.

A> Does this apply to PyArg_ParseTuple ?

Yeah, I've seen -Wformat before and Goswin mentioned it as well.
However, looking at the GCC documentation I doubt it would help for
PyArg_ParseTuple() as this feature only seems to apply to printf(),
scanf(), strftime(), and strfmon() and related functions.

Thanks for pointing out that Zope 2.7 has been fixed.

Per

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



Reply to: