py-libxml2: work around a problem in error handling Restore part of a patch lost in the last libxml2 update which is still relevant. Reapplying it fixes segfaults caused by itstool, e.g., when building editors/pluma, which is PR pkg/56229 from Andrius V. Quoting from wiz@'s original commit from Jan 9, 2019, which covers everything else: "In some cases, invalid UTF-8 strings were returned which caused Python interpreter crashes. See itstool/itstool#22 Use a variant of the patch that was used in Fedora. Bump PKGREVISION." Fedora is still carrying this patch as-is. (Also, evidently distinfo was not regenerated properly after the last update, so there's a diff applied to it unrelated to this change set.)diff -r1.135 -r1.136 pkgsrc/textproc/libxml2/distinfo
(gutteridge)
@@ -1,19 +1,16 @@ | @@ -1,19 +1,16 @@ | |||
1 | $NetBSD: distinfo,v 1.135 2021/05/23 19:31:47 nia Exp $ | 1 | $NetBSD: distinfo,v 1.136 2021/06/12 17:02:51 gutteridge Exp $ | |
2 | 2 | |||
3 | SHA1 (libxml2-2.9.12.tar.gz) = 339fe5bb2a7d0c13f068c26d8f7cd194c13f9a2a | 3 | SHA1 (libxml2-2.9.12.tar.gz) = 339fe5bb2a7d0c13f068c26d8f7cd194c13f9a2a | |
4 | RMD160 (libxml2-2.9.12.tar.gz) = 766b9460b9e62b8152f431747c30c88c868c0c7e | 4 | RMD160 (libxml2-2.9.12.tar.gz) = 766b9460b9e62b8152f431747c30c88c868c0c7e | |
5 | SHA512 (libxml2-2.9.12.tar.gz) = df1c6486e80f0fcf3c506f3599bcfb94b620c00d0b5d26831bc983daa78d58ec58b5057b1ec7c1a26c694f40199c6234ee2a6dcabf65abfa10c447cb5705abbd | 5 | SHA512 (libxml2-2.9.12.tar.gz) = df1c6486e80f0fcf3c506f3599bcfb94b620c00d0b5d26831bc983daa78d58ec58b5057b1ec7c1a26c694f40199c6234ee2a6dcabf65abfa10c447cb5705abbd | |
6 | Size (libxml2-2.9.12.tar.gz) = 5681632 bytes | 6 | Size (libxml2-2.9.12.tar.gz) = 5681632 bytes | |
7 | SHA1 (patch-Makefile.in) = e687eaa9805b855b0c8a944ec5c597bd34954472 | 7 | SHA1 (patch-Makefile.in) = e687eaa9805b855b0c8a944ec5c597bd34954472 | |
8 | SHA1 (patch-catalog.c) = 34afe787f6012b460a85be993048e133907a1621 | 8 | SHA1 (patch-catalog.c) = 34afe787f6012b460a85be993048e133907a1621 | |
9 | SHA1 (patch-configure) = f6e9f08377a537657df08deee17a5cc66c60b808 | 9 | SHA1 (patch-configure) = f6e9f08377a537657df08deee17a5cc66c60b808 | |
10 | SHA1 (patch-doc_examples_Makefile.in) = 4eede9719724f94402e850ee6d6043a74aaf62b2 | 10 | SHA1 (patch-doc_examples_Makefile.in) = 4eede9719724f94402e850ee6d6043a74aaf62b2 | |
11 | SHA1 (patch-encoding.c) = 62b3343f0a0ea51e3fb8eb693e495520eefb6ffd | 11 | SHA1 (patch-encoding.c) = 62b3343f0a0ea51e3fb8eb693e495520eefb6ffd | |
12 | SHA1 (patch-parser.c) = 9dcda6b8bc71c1abb095fc2c840ac40c1ae04a33 | 12 | SHA1 (patch-python_libxml.c) = a8d89922589f51db99c2b8960b32d37ddda8a7a9 | |
13 | SHA1 (patch-python-types.c) = d3c93a1c68956bc7da4f81a8fcbf1e6bad580bef | |||
14 | SHA1 (patch-python_libxml.c) = c092f10787be1bb43764cc0bef4ffd35bbe6ec94 | |||
15 | SHA1 (patch-python_libxml.py) = 869a72ae5ba2e27e6d46552878890acb22337675 | 13 | SHA1 (patch-python_libxml.py) = 869a72ae5ba2e27e6d46552878890acb22337675 | |
16 | SHA1 (patch-python_libxml2.py) = 209d105b0f3aedb834091390a7c6819705108e34 | 14 | SHA1 (patch-python_libxml2.py) = 209d105b0f3aedb834091390a7c6819705108e34 | |
17 | SHA1 (patch-python_setup.py) = 7771fd02ee6779463f1d3321f099d7e6d19cd1b1 | 15 | SHA1 (patch-python_setup.py) = 7771fd02ee6779463f1d3321f099d7e6d19cd1b1 | |
18 | SHA1 (patch-xmlcatalog.c) = d65b7e3be9694147e96ce4bb70a1739e2279ba81 | 16 | SHA1 (patch-xmlcatalog.c) = d65b7e3be9694147e96ce4bb70a1739e2279ba81 | |
19 | SHA1 (patch-xmlschemas.c) = edd5be08e7b19ab8e35412b854e95dedbb7befdd |
$NetBSD: patch-python_libxml.c,v 1.4 2021/06/12 17:02:51 gutteridge Exp $
Avoid returning invalid UTF-8 strings to Python.
Based on https://bugzilla.opensuse.org/attachment.cgi?id=746044&action=edit
Fixes https://github.com/itstool/itstool/issues/22
--- python/libxml.c.orig 2016-06-07 10:04:14.000000000 +0000
+++ 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,10 +1637,14 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
str[999] = 0;
va_end(ap);
+ /* Ensure the error string doesn't start at UTF8 continuation. */
+ while (*ptr && (*ptr & 0xc0) == 0x80)
+ ptr++;
+
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);
Py_XDECREF(list);
@@ -1,18 +1,19 @@ | @@ -1,18 +1,19 @@ | |||
1 | # $NetBSD: Makefile,v 1.68 2021/05/23 19:31:47 nia Exp $ | 1 | # $NetBSD: Makefile,v 1.69 2021/06/12 17:02:51 gutteridge Exp $ | |
2 | 2 | |||
3 | .include "../../textproc/libxml2/Makefile.common" | 3 | .include "../../textproc/libxml2/Makefile.common" | |
4 | 4 | |||
5 | PKGNAME= ${PYPKGPREFIX}-${DISTNAME} | 5 | PKGNAME= ${PYPKGPREFIX}-${DISTNAME} | |
6 | PKGREVISION= 1 | |||
6 | 7 | |||
7 | COMMENT= Python wrapper for libxml2 | 8 | COMMENT= Python wrapper for libxml2 | |
8 | LICENSE= modified-bsd | 9 | LICENSE= modified-bsd | |
9 | 10 | |||
10 | USE_GCC_RUNTIME= yes | 11 | USE_GCC_RUNTIME= yes | |
11 | 12 | |||
12 | PYSETUPSUBDIR= python | 13 | PYSETUPSUBDIR= python | |
13 | NO_CONFIGURE= YES | 14 | NO_CONFIGURE= YES | |
14 | 15 | |||
15 | SUBST_CLASSES+= setup | 16 | SUBST_CLASSES+= setup | |
16 | SUBST_MESSAGE.setup= Fixing hardcoded paths. | 17 | SUBST_MESSAGE.setup= Fixing hardcoded paths. | |
17 | SUBST_STAGE.setup= pre-build | 18 | SUBST_STAGE.setup= pre-build | |
18 | SUBST_FILES.setup= python/setup.py | 19 | SUBST_FILES.setup= python/setup.py |