guix-commits
[Top][All Lists]
Advanced

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

01/01: gnu: python-libxml2, itstool: Provide crash-free variants.


From: guix-commits
Subject: 01/01: gnu: python-libxml2, itstool: Provide crash-free variants.
Date: Fri, 20 Sep 2019 06:29:29 -0400 (EDT)

civodul pushed a commit to branch core-updates
in repository guix.

commit 3a2efbc8670f72a524cc7290e11559cdb42852a4
Author: Ludovic Courtès <address@hidden>
Date:   Fri Sep 20 12:21:19 2019 +0200

    gnu: python-libxml2, itstool: Provide crash-free variants.
    
    Fixes <https://bugs.gnu.org/37468>.
    
    * gnu/packages/patches/python-libxml2-utf8.patch: New file.
    * gnu/local.mk (dist_patch_DATA): Add it.
    * gnu/packages/xml.scm (python-libxml2/fixed): New variable.
    * gnu/packages/glib.scm (itstool/fixed): New variable.
    * gnu/packages/gnome.scm (gnumeric)[native-inputs]: Use ITSTOOL/FIXED
    instead of ITSTOOL.
---
 gnu/local.mk                                   |  1 +
 gnu/packages/glib.scm                          | 11 +++++++
 gnu/packages/gnome.scm                         |  2 +-
 gnu/packages/patches/python-libxml2-utf8.patch | 40 ++++++++++++++++++++++++++
 gnu/packages/xml.scm                           | 15 +++++++++-
 5 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/gnu/local.mk b/gnu/local.mk
index 63d55c5..5705494 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1252,6 +1252,7 @@ dist_patch_DATA =                                         
\
   %D%/packages/patches/python-keras-integration-test.patch     \
   %D%/packages/patches/python-pyfakefs-remove-bad-test.patch   \
   %D%/packages/patches/python-flint-includes.patch             \
+  %D%/packages/patches/python-libxml2-utf8.patch               \
   %D%/packages/patches/python-mox3-python3.6-compat.patch      \
   %D%/packages/patches/python-testtools.patch                  \
   %D%/packages/patches/python-paste-remove-timing-test.patch   \
diff --git a/gnu/packages/glib.scm b/gnu/packages/glib.scm
index ad000ad..a2f0f2f 100644
--- a/gnu/packages/glib.scm
+++ b/gnu/packages/glib.scm
@@ -65,6 +65,7 @@
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix utils)
+  #:use-module (srfi srfi-1)
 
   ;; Export variables up-front to allow circular dependency with the 'xorg'
   ;; module.
@@ -495,6 +496,16 @@ information in their documents, such as whether a 
particular element should be
 translated.")
     (license license:gpl3+)))
 
+(define-public itstool/fixed
+  ;; This variant fixes a python-libxml2 crash when processing UTF-8
+  ;; sequences: <https://bugs.gnu.org/37468>.  Since the issue is quite rare,
+  ;; create this variant here to avoid a full rebuild.
+  (package/inherit
+   itstool
+   (inputs
+    `(("python-libxml2" ,python-libxml2/fixed)
+      ,@(alist-delete "python-libxml2" (package-inputs itstool))))))
+
 (define dbus-glib
   (package
     (name "dbus-glib")
diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index 520d04d..03550b6 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -2167,7 +2167,7 @@ Hints specification (EWMH).")
      `(("bison" ,bison)
        ("docbook-xml" ,docbook-xml)
        ("intltool" ,intltool)
-       ("itstool" ,itstool)
+       ("itstool" ,itstool/fixed)            ;see <https://bugs.gnu.org/37468>
        ("glib:bin" ,glib "bin")
        ("pkg-config" ,pkg-config)))
     (home-page "http://www.gnumeric.org";)
diff --git a/gnu/packages/patches/python-libxml2-utf8.patch 
b/gnu/packages/patches/python-libxml2-utf8.patch
new file mode 100644
index 0000000..e39672f
--- /dev/null
+++ b/gnu/packages/patches/python-libxml2-utf8.patch
@@ -0,0 +1,40 @@
+This patch fixes a crash in the libxml2 bindings for Python 3.x
+that 'itstool' stumbles upon when processing UTF-8 data:
+
+  https://issues.guix.gnu.org/issue/37468
+
+Patch by Jan Matejek
+from <https://bugzilla.opensuse.org/show_bug.cgi?id=1065270>.
+
+--- libxml2-2.9.5.orig/python/libxml.c
++++ libxml2-2.9.5/python/libxml.c
+@@ -1620,6 +1620,7 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
+     PyObject *message;
+     PyObject *result;
+     char str[1000];
++    unsigned char *ptr = (unsigned char *)str;
+ 
+ #ifdef DEBUG_ERROR
+     printf("libxml_xmlErrorFuncHandler(%p, %s, ...) called\n", ctx, msg);
+@@ -1636,12 +1637,20 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
+           str[999] = 0;
+         va_end(ap);
+ 
++#if PY_MAJOR_VERSION >= 3
++        /* Ensure the error string doesn't start at UTF8 continuation. */
++        while (*ptr && (*ptr & 0xc0) == 0x80)
++            ptr++;
++#endif
++
+         list = PyTuple_New(2);
+         PyTuple_SetItem(list, 0, libxml_xmlPythonErrorFuncCtxt);
+         Py_XINCREF(libxml_xmlPythonErrorFuncCtxt);
+-        message = libxml_charPtrConstWrap(str);
++        message = libxml_charPtrConstWrap(ptr);
+         PyTuple_SetItem(list, 1, message);
+         result = PyEval_CallObject(libxml_xmlPythonErrorFuncHandler, list);
++        /* Forget any errors caused in the error handler. */
++        PyErr_Clear();
+         Py_XDECREF(list);
+         Py_XDECREF(result);
+     }
diff --git a/gnu/packages/xml.scm b/gnu/packages/xml.scm
index 78b9b71..b8f3774 100644
--- a/gnu/packages/xml.scm
+++ b/gnu/packages/xml.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2016, 2018 Ludovic Courtès <address@hidden>
+;;; Copyright © 2013, 2014, 2015, 2016, 2018, 2019 Ludovic Courtès 
<address@hidden>
 ;;; Copyright © 2013, 2015 Andreas Enge <address@hidden>
 ;;; Copyright © 2015 Eric Bavier <address@hidden>
 ;;; Copyright © 2015 Sou Bunnbu <address@hidden>
@@ -164,6 +164,7 @@ project (but it is usable outside of the Gnome platform).")
     (license license:x11)))
 
 (define-public python-libxml2
+  ;; TODO: Merge with 'python-libxml2/fixed' on the next rebuild cycle.
   (package/inherit libxml2
     (name "python-libxml2")
     (build-system python-build-system)
@@ -191,6 +192,18 @@ project (but it is usable outside of the Gnome platform).")
     (inputs `(("libxml2" ,libxml2)))
     (synopsis "Python bindings for the libxml2 library")))
 
+(define-public python-libxml2/fixed
+  ;; This variant fixes a crash when processing UTF-8 sequences:
+  ;;    <https://bugs.gnu.org/37468>
+  ;; TODO: Merge with 'python-libxml2' on the next rebuild cycle.
+  (package/inherit
+   python-libxml2
+   (version (string-append (package-version python-libxml2) "-1"))
+   (source (origin
+             (inherit (package-source libxml2))
+             (patches (cons (search-patch "python-libxml2-utf8.patch")
+                            (origin-patches (package-source libxml2))))))))
+
 (define-public python2-libxml2
   (package-with-python2 python-libxml2))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]