Add patch to fix crash: xmlParserPrintFileContextInternal mangles utf8

This commit is contained in:
Björn Esser 2019-01-06 21:24:34 +01:00
parent 06a8f6badc
commit 53286c556c
No known key found for this signature in database
GPG Key ID: F52E98007594C21D
2 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,34 @@
Index: libxml2-2.9.5/python/libxml.c
===================================================================
--- 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);
}

View File

@ -1,6 +1,6 @@
Name: libxml2
Version: 2.9.8
Release: 4%{?dist}
Release: 5%{?dist}
Summary: Library providing XML and HTML support
License: MIT
@ -21,6 +21,9 @@ Patch0010: 0010-Remove-a-misleading-line-from-xmlCharEncOutput.patch
Patch0011: 0011-Remove-stray-character-from-comment.patch
Patch0012: 0012-Fix-nullptr-deref-with-XPath-logic-ops.patch
Patch0013: 0013-Fix-infinite-loop-in-LZMA-decompression.patch
# Patch from openSUSE.
# See: https://bugzilla.gnome.org/show_bug.cgi?id=789714
Patch0014: libxml2-2.9.8-python3-unicode-errors.patch
BuildRequires: autoconf
BuildRequires: automake
@ -182,6 +185,9 @@ gzip -9 -c doc/libxml2-api.xml > doc/libxml2-api.xml.gz
%{python3_sitearch}/libxml2mod.so
%changelog
* Sun Jan 06 2019 Björn Esser <besser82@fedoraproject.org> - 2.9.8-5
- Add patch to fix crash: xmlParserPrintFileContextInternal mangles utf8
* Thu Aug 02 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 2.9.8-4
- Backport patches from upstream