Control: tags -1 patch

Hi Michael,
On Wed, 5 Oct 2016 22:12:19 +0200 Michael Biebl <bi...@debian.org> wrote:
>
> Hi
>
> Am 05.10.2016 um 22:06 schrieb John Paul Adrian Glaubitz:
> > pygtk currently fails to build from source on sparc64 due to a bus error in
> > one of the tests in the testsuite:
>
> [..]
>
> > Feel free to ask on debian-sp...@list.debian.org in any case.
>
> We are happy to take a patch for that. It would be great if you can also
> forward this upstream.

Please find attached a patch to fix this.

The call to PyArg_ParseTupleAndKeywords uses "k" in the format string
for &colour.pixel, which means unsigned long (as you can see in
src:python2.7/Python/getargs.c), but the pixel field is a guint32, and
of course, unsigned long is 64-bit here. I'm very surprised this hasn't
led to memory corruption of the subsequent fields in the struct, as it's
only thanks to the alignment requirements on SPARC that this was
noticed.

Anyway, since there's no easy way to specify a 32-bit int in the format
string (other than determining at compile time based on the size of
short/int/long which to use), I've introduced a local unsigned long
temporary. It should probably check that "pixel <= UINT32_MAX" and give
a suitable error message, but I'll leave that to someone who knows what
they're doing with Python modules.

Is upstream still accepting patches? https://git.gnome.org/browse/pygtk/
doesn't show any activity since 2013...

Regards,
James

PS: If you're touching the packaging, the unpatch rule in d/rules is
    broken, since it deletes .pc, but doesn't actually unpatch, so once
    clean is run (which depends on unpatch), quilt is broken. Either
    unpatch should actually quilt pop -a (but then clean shouldn't
    depend on it, since that's wrong for a 3.0 (quilt) package), or it
    shouldn't delete .pc, but the current behaviour is incredibly
    frustrating to work with.
--- a/gtk/gdkcolor.override
+++ b/gtk/gdkcolor.override
@@ -33,6 +33,7 @@ _wrap_gdk_color_new(PyGBoxed *self,
     static char *kwlist1[] = {"red", "green", "blue", "pixel", NULL };
     static char *kwlist2[] = { "spec", NULL };
     PyObject *red = Py_None, *green = Py_None, *blue = Py_None;
+    unsigned long pixel;
     const char *spec = NULL;
     GdkColor colour;
 
@@ -56,7 +57,9 @@ _wrap_gdk_color_new(PyGBoxed *self,
     PyErr_Clear();
 
     if (PyArg_ParseTupleAndKeywords(args, kwargs, "|OOOk:gdk.Color", kwlist1,
-                                    &red, &green, &blue, &colour.pixel)) {
+                                    &red, &green, &blue, &pixel)) {
+        colour.pixel = pixel;
+
         /* We don't allow mixing floats and non-floats as that is too
          * error-prone.  All non-floats are deemed integers in case
          * they have __int__() method. */

Attachment: signature.asc
Description: PGP signature

Reply via email to