Skip to content

Commit eaadea6

Browse files
committed
Merge commit '66453240c94b5cbd3e9ae9b32016fdafb13cdf18'
2 parents 00f2eeb + 6645324 commit eaadea6

26 files changed

+482
-174
lines changed

.gitlab-ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
include:
2+
- component: "gitlab.gnome.org/GNOME/citemplates/release-service@master"
3+
inputs:
4+
dist-job-name: "dist"
5+
tarball-artifact-path: "libxml2-dist/libxml2-2.13.6.tar.xz"
6+
17
.test:
28
image: registry.gitlab.gnome.org/gnome/libxml2
39
variables:
@@ -286,6 +292,14 @@ cmake:linux:gcc:shared:
286292
CC: gcc
287293
SUFFIX: linux-gcc-shared
288294

295+
dist:
296+
image: registry.gitlab.gnome.org/gnome/libxml2
297+
script:
298+
- sh .gitlab-ci/dist.sh
299+
artifacts:
300+
paths:
301+
- libxml2-dist/*.tar.xz
302+
289303
pages:
290304
script:
291305
- mkdir -p public

.gitlab-ci/dist.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
mkdir -p libxml2-dist
6+
cd libxml2-dist
7+
sh ../autogen.sh
8+
make distcheck V=1 DISTCHECK_CONFIGURE_FLAGS='--with-legacy'
9+
if [ -z "$CI_COMMIT_TAG" ]; then
10+
mv libxml2-*.tar.xz libxml2-git-$CI_COMMIT_SHORT_SHA.tar.xz
11+
fi

CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ if (NOT MSVC)
149149
check_function_exists(stat HAVE_STAT)
150150
check_include_files(stdint.h HAVE_STDINT_H)
151151
check_include_files(sys/mman.h HAVE_SYS_MMAN_H)
152-
check_include_files(sys/random.h HAVE_SYS_RANDOM_H)
152+
if (APPLE)
153+
# In old macOS SDKs (ex: 10.15), sys/random.h fails to include header files it needs, so add them here.
154+
check_include_files("Availability.h;stddef.h;sys/random.h" HAVE_SYS_RANDOM_H)
155+
else()
156+
check_include_files(sys/random.h HAVE_SYS_RANDOM_H)
157+
endif()
153158
check_include_files(sys/select.h HAVE_SYS_SELECT_H)
154159
check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
155160
check_include_files(sys/stat.h HAVE_SYS_STAT_H)
@@ -549,7 +554,7 @@ if(LIBXML2_WITH_PYTHON)
549554
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libxml2.py.in "${LIBXML2CLASS_PY}")
550555
configure_file(${CMAKE_CURRENT_BINARY_DIR}/libxml2.py.in libxml2.py COPYONLY)
551556
add_library(
552-
LibXml2Mod
557+
LibXml2Mod SHARED
553558
libxml2-py.c
554559
libxml2-py.h
555560
python/libxml.c
@@ -611,7 +616,7 @@ install(
611616
write_basic_package_version_file(
612617
${CMAKE_CURRENT_BINARY_DIR}/libxml2-config-version.cmake
613618
VERSION ${PROJECT_VERSION}
614-
COMPATIBILITY ExactVersion
619+
COMPATIBILITY SameMajorVersion
615620
)
616621

617622
install(

NEWS

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,50 @@
11
NEWS file for libxml2
22

3+
v2.13.6: Feb 18 2025
4+
5+
### Security
6+
7+
- [CVE-2025-24928] Fix stack-buffer-overflow in xmlSnprintfElements
8+
- [CVE-2024-56171] Fix use-after-free after xmlSchemaItemListAdd
9+
- pattern: Fix compilation of explicit child axis
10+
11+
### Regressions
12+
13+
- xmllint: Support compressed input from stdin
14+
- uri: Fix handling of Windows drive letters
15+
- reader: Fix return value of xmlTextReaderReadString again
16+
- SAX2: Fix xmlSAX2ResolveEntity if systemId is NULL
17+
18+
### Portability
19+
20+
- dict: Handle ENOSYS from getentropy gracefully
21+
- Fix compilation with uclibc (Dario Binacchi)
22+
- python: Declare init func with PyMODINIT_FUNC
23+
- tests: Fix sanitizer version check on old Apple clang
24+
- cmake: Work around broken sys/random.h in old macOS SDKs
25+
26+
### Build
27+
28+
- autotools: Set AC_CONFIG_AUX_DIR
29+
- cmake: Always build Python module as shared library
30+
- cmake: add missing `Bcrypt` link on Windows (Saleem Abdulrasool)
31+
- cmake: Fix compatibility in package version file
32+
33+
334
v2.13.5: Nov 12 2024
435

536
### Regressions
637

7-
- xmlIO: Fix reading from non-regular files like pipes (Nick Wellnhofer)
8-
- xmlreader: Fix return value of xmlTextReaderReadString (Nick Wellnhofer)
9-
- parser: Fix loading of parameter entities in external DTDs (Nick Wellnhofer)
10-
- parser: Fix downstream code that swaps DTDs (Nick Wellnhofer)
11-
- parser: Fix detection of duplicate attributes (Nick Wellnhofer)
12-
- string: Fix va_copy fallback (Nick Wellnhofer)
38+
- xmlIO: Fix reading from non-regular files like pipes
39+
- xmlreader: Fix return value of xmlTextReaderReadString
40+
- parser: Fix loading of parameter entities in external DTDs
41+
- parser: Fix downstream code that swaps DTDs
42+
- parser: Fix detection of duplicate attributes
43+
- string: Fix va_copy fallback
1344

1445
### Bug fixes
1546

16-
- xpath: Fix parsing of non-ASCII names (Nick Wellnhofer)
47+
- xpath: Fix parsing of non-ASCII names
1748

1849

1950
v2.13.4: Sep 18 2024

SAX2.c

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -404,42 +404,48 @@ xmlSAX2ResolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId
404404
{
405405
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
406406
xmlParserInputPtr ret = NULL;
407-
xmlChar *URI;
408-
const xmlChar *base = NULL;
409-
int res;
407+
xmlChar *URI = NULL;
410408

411409
if (ctx == NULL) return(NULL);
412-
if (ctxt->input != NULL)
413-
base = BAD_CAST ctxt->input->filename;
414410

415-
/*
416-
* We don't really need the 'directory' struct member, but some
417-
* users set it manually to a base URI for memory streams.
418-
*/
419-
if (base == NULL)
420-
base = BAD_CAST ctxt->directory;
411+
if (systemId != NULL) {
412+
const xmlChar *base = NULL;
413+
int res;
421414

422-
if ((xmlStrlen(systemId) > XML_MAX_URI_LENGTH) ||
423-
(xmlStrlen(base) > XML_MAX_URI_LENGTH)) {
424-
xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long");
425-
return(NULL);
426-
}
427-
res = xmlBuildURISafe(systemId, base, &URI);
428-
if (URI == NULL) {
429-
if (res < 0)
430-
xmlSAX2ErrMemory(ctxt);
431-
else
432-
xmlWarnMsg(ctxt, XML_ERR_INVALID_URI,
433-
"Can't resolve URI: %s\n", systemId);
434-
return(NULL);
435-
}
436-
if (xmlStrlen(URI) > XML_MAX_URI_LENGTH) {
437-
xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long");
438-
} else {
439-
ret = xmlLoadExternalEntity((const char *) URI,
440-
(const char *) publicId, ctxt);
415+
if (ctxt->input != NULL)
416+
base = BAD_CAST ctxt->input->filename;
417+
418+
/*
419+
* We don't really need the 'directory' struct member, but some
420+
* users set it manually to a base URI for memory streams.
421+
*/
422+
if (base == NULL)
423+
base = BAD_CAST ctxt->directory;
424+
425+
if ((xmlStrlen(systemId) > XML_MAX_URI_LENGTH) ||
426+
(xmlStrlen(base) > XML_MAX_URI_LENGTH)) {
427+
xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long");
428+
return(NULL);
429+
}
430+
res = xmlBuildURISafe(systemId, base, &URI);
431+
if (URI == NULL) {
432+
if (res < 0)
433+
xmlSAX2ErrMemory(ctxt);
434+
else
435+
xmlWarnMsg(ctxt, XML_ERR_INVALID_URI,
436+
"Can't resolve URI: %s\n", systemId);
437+
return(NULL);
438+
}
439+
if (xmlStrlen(URI) > XML_MAX_URI_LENGTH) {
440+
xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long");
441+
xmlFree(URI);
442+
return(NULL);
443+
}
441444
}
442445

446+
ret = xmlLoadExternalEntity((const char *) URI,
447+
(const char *) publicId, ctxt);
448+
443449
xmlFree(URI);
444450
return(ret);
445451
}

configure.ac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ AC_PREREQ([2.63])
33

44
m4_define([MAJOR_VERSION], 2)
55
m4_define([MINOR_VERSION], 13)
6-
m4_define([MICRO_VERSION], 5)
6+
m4_define([MICRO_VERSION], 6)
77

88
AC_INIT([libxml2],[MAJOR_VERSION.MINOR_VERSION.MICRO_VERSION])
99
AC_CONFIG_SRCDIR([entities.c])
1010
AC_CONFIG_HEADERS([config.h])
1111
AC_CONFIG_MACRO_DIR([m4])
12+
AC_CONFIG_AUX_DIR([.])
1213
AC_CANONICAL_HOST
1314

1415
LIBXML_MAJOR_VERSION=MAJOR_VERSION

dict.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -928,14 +928,15 @@ xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name) {
928928
#define WIN32_LEAN_AND_MEAN
929929
#include <windows.h>
930930
#include <bcrypt.h>
931-
#elif defined(HAVE_GETENTROPY)
932-
#ifdef HAVE_UNISTD_H
933-
#include <unistd.h>
934-
#endif
935-
#ifdef HAVE_SYS_RANDOM_H
936-
#include <sys/random.h>
937-
#endif
938931
#else
932+
#if defined(HAVE_GETENTROPY)
933+
#ifdef HAVE_UNISTD_H
934+
#include <unistd.h>
935+
#endif
936+
#ifdef HAVE_SYS_RANDOM_H
937+
#include <sys/random.h>
938+
#endif
939+
#endif
939940
#include <time.h>
940941
#endif
941942

@@ -965,9 +966,21 @@ xmlInitRandom(void) {
965966
"error code %lu\n", GetLastError());
966967
abort();
967968
}
968-
#elif defined(HAVE_GETENTROPY)
969+
#else
970+
int var;
971+
972+
#if defined(HAVE_GETENTROPY)
969973
while (1) {
970974
if (getentropy(globalRngState, sizeof(globalRngState)) == 0)
975+
return;
976+
977+
/*
978+
* This most likely means that libxml2 was compiled on
979+
* a system supporting certain system calls and is running
980+
* on a system that doesn't support these calls, as can
981+
* be the case on Linux.
982+
*/
983+
if (errno == ENOSYS)
971984
break;
972985

973986
if (errno != EINTR) {
@@ -976,8 +989,7 @@ xmlInitRandom(void) {
976989
abort();
977990
}
978991
}
979-
#else
980-
int var;
992+
#endif
981993

982994
globalRngState[0] =
983995
(unsigned) time(NULL) ^

encoding.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ DECLARE_ISO_FUNCS(16)
12641264
#endif /* LIBXML_ISO8859X_ENABLED */
12651265

12661266
#ifdef LIBXML_ICONV_ENABLED
1267-
#define EMPTY_ICONV , (iconv_t) 0, (iconv_t) 0
1267+
#define EMPTY_ICONV , (iconv_t) -1, (iconv_t) -1
12681268
#else
12691269
#define EMPTY_ICONV
12701270
#endif
@@ -1389,8 +1389,8 @@ xmlNewCharEncodingHandler(const char *name,
13891389
handler->name = up;
13901390

13911391
#ifdef LIBXML_ICONV_ENABLED
1392-
handler->iconv_in = NULL;
1393-
handler->iconv_out = NULL;
1392+
handler->iconv_in = (iconv_t) -1;
1393+
handler->iconv_out = (iconv_t) -1;
13941394
#endif
13951395
#ifdef LIBXML_ICU_ENABLED
13961396
handler->uconv_in = NULL;
@@ -1641,6 +1641,10 @@ xmlCreateUconvHandler(const char *name, xmlCharEncodingHandler **out) {
16411641
}
16421642
enc->input = NULL;
16431643
enc->output = NULL;
1644+
#ifdef LIBXML_ICONV_ENABLED
1645+
enc->iconv_in = (iconv_t) -1;
1646+
enc->iconv_out = (iconv_t) -1;
1647+
#endif
16441648
enc->uconv_in = ucv_in;
16451649
enc->uconv_out = ucv_out;
16461650

@@ -2200,7 +2204,7 @@ xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
22002204
}
22012205
}
22022206
#ifdef LIBXML_ICONV_ENABLED
2203-
else if (handler->iconv_in != NULL) {
2207+
else if (handler->iconv_in != (iconv_t) -1) {
22042208
ret = xmlIconvWrapper(handler->iconv_in, out, outlen, in, inlen);
22052209
}
22062210
#endif /* LIBXML_ICONV_ENABLED */
@@ -2260,7 +2264,7 @@ xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
22602264
}
22612265
}
22622266
#ifdef LIBXML_ICONV_ENABLED
2263-
else if (handler->iconv_out != NULL) {
2267+
else if (handler->iconv_out != (iconv_t) -1) {
22642268
ret = xmlIconvWrapper(handler->iconv_out, out, outlen, in, inlen);
22652269
}
22662270
#endif /* LIBXML_ICONV_ENABLED */
@@ -2672,17 +2676,17 @@ xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
26722676
* Iconv handlers can be used only once, free the whole block.
26732677
* and the associated icon resources.
26742678
*/
2675-
if ((handler->iconv_out != NULL) || (handler->iconv_in != NULL)) {
2679+
if ((handler->iconv_out != (iconv_t) -1) || (handler->iconv_in != (iconv_t) -1)) {
26762680
tofree = 1;
2677-
if (handler->iconv_out != NULL) {
2681+
if (handler->iconv_out != (iconv_t) -1) {
26782682
if (iconv_close(handler->iconv_out))
26792683
ret = -1;
2680-
handler->iconv_out = NULL;
2684+
handler->iconv_out = (iconv_t) -1;
26812685
}
2682-
if (handler->iconv_in != NULL) {
2686+
if (handler->iconv_in != (iconv_t) -1) {
26832687
if (iconv_close(handler->iconv_in))
26842688
ret = -1;
2685-
handler->iconv_in = NULL;
2689+
handler->iconv_in = (iconv_t) -1;
26862690
}
26872691
}
26882692
#endif /* LIBXML_ICONV_ENABLED */

include/private/io.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ XML_HIDDEN xmlParserInputBufferPtr
2424
xmlNewInputBufferMemory(const void *mem, size_t size, int flags,
2525
xmlCharEncoding enc);
2626

27+
XML_HIDDEN int
28+
xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int unzip);
29+
2730
#ifdef LIBXML_OUTPUT_ENABLED
2831
XML_HIDDEN xmlOutputBufferPtr
2932
xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder);

include/private/parser.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ xmlParserNsLookupSax(xmlParserCtxtPtr ctxt, const xmlChar *prefix);
9090

9191
#define XML_INPUT_BUF_STATIC (1u << 1)
9292
#define XML_INPUT_BUF_ZERO_TERMINATED (1u << 2)
93+
#define XML_INPUT_UNZIP (1u << 3)
94+
95+
/* Internal parser option */
96+
#define XML_PARSE_UNZIP (1 << 24)
9397

9498
XML_HIDDEN xmlParserInputPtr
9599
xmlNewInputURL(xmlParserCtxtPtr ctxt, const char *url, const char *publicId,

libxml.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
#endif
5656

5757
#ifdef __clang__
58-
#if __clang_major__ >= 12
58+
#if (!defined(__apple_build_version__) && __clang_major__ >= 12) || \
59+
(defined(__apple_build_version__) && __clang_major__ >= 13)
5960
#define ATTRIBUTE_NO_SANITIZE_INTEGER \
6061
ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow") \
6162
ATTRIBUTE_NO_SANITIZE("unsigned-shift-base")

libxml2-config.cmake.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ if(NOT LIBXML2_SHARED)
157157
endif()
158158

159159
if(WIN32)
160-
list(APPEND LIBXML2_LIBRARIES ws2_32)
160+
list(APPEND LIBXML2_LIBRARIES ws2_32;Bcrypt)
161161
endif()
162162
endif()
163163

libxml2-config.cmake.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ if(UNIX)
113113
endif()
114114

115115
if(WIN32)
116-
list(APPEND LIBXML2_LIBRARIES ws2_32)
117-
list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:ws2_32>")
116+
list(APPEND LIBXML2_LIBRARIES ws2_32;Bcrypt)
117+
list(APPEND LIBXML2_INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:ws2_32>;\$<LINK_ONLY:Bcrypt>")
118118
endif()
119119

120120
# whether libxml2 has dso support

0 commit comments

Comments
 (0)