diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2021-05-10 17:36:49 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2021-05-10 17:36:49 +0000 |
commit | cc4e1e0440f1af1adb7fbcae5d0762ecd3c2114a (patch) | |
tree | 5bd941129776e08e4df16e51799d46ab6bfedd74 /lib/libexpat | |
parent | c3fc5670031608bfcb0f970330e3bc119ab48333 (diff) |
Update libexpat to 2.3.0. Relevant for OpenBSD are only bug fix
#438 and other change #443. A new error constant has been added
to a public header file. According to guenther@ this is an ABI
break that requires a major bump.
OK tb@; tested by matthieu@
Diffstat (limited to 'lib/libexpat')
-rw-r--r-- | lib/libexpat/Changes | 51 | ||||
-rw-r--r-- | lib/libexpat/README.md | 80 | ||||
-rw-r--r-- | lib/libexpat/lib/expat.h | 10 | ||||
-rw-r--r-- | lib/libexpat/lib/siphash.h | 13 | ||||
-rw-r--r-- | lib/libexpat/lib/xmlparse.c | 24 | ||||
-rw-r--r-- | lib/libexpat/lib/xmltok.c | 10 | ||||
-rw-r--r-- | lib/libexpat/shlib_version | 2 | ||||
-rw-r--r-- | lib/libexpat/tests/minicheck.c | 29 | ||||
-rw-r--r-- | lib/libexpat/tests/runtests.c | 35 |
9 files changed, 180 insertions, 74 deletions
diff --git a/lib/libexpat/Changes b/lib/libexpat/Changes index b74a7c56a96..edd485c8dd0 100644 --- a/lib/libexpat/Changes +++ b/lib/libexpat/Changes @@ -2,6 +2,55 @@ NOTE: We are looking for help with a few things: https://github.com/libexpat/libexpat/labels/help%20wanted If you can help, please get in touch. Thanks! +Release 2.3.0 Thu March 25 2021 + Bug fixes: + #438 When calling XML_ParseBuffer without a prior successful call to + XML_GetBuffer as a user, no longer trigger undefined behavior + (by adding an integer to a NULL pointer) but rather return + XML_STATUS_ERROR and set the error code to (new) code + XML_ERROR_NO_BUFFER. Found by UBSan (UndefinedBehaviorSanitizer) + of Clang 11 (but not Clang 9). + #444 xmlwf: Exit status 2 was used for both: + - malformed input files (documented) and + - invalid command-line arguments (undocumented). + The case of invalid command-line arguments now + has its own exit status 4, resolving the ambiguity. + + Other changes: + #439 xmlwf: Add argument -k to allow continuing after + non-fatal errors + #439 xmlwf: Add section about exit status to the -h help output + #422 #426 #447 Windows: Drop support for Visual Studio <=14.0/2015 + #434 Windows: CMake: Detect unsupported Visual Studio at + configure time (rather than at compile time) + #382 #428 testrunner: Make verbose mode (argument "-v") report + about passed tests, and make default mode report about + failures, as well. + #442 CMake: Call "enable_language(CXX)" prior to tinkering + with CMAKE_CXX_* variables + #448 Document use of libexpat from a CMake-based project + #451 Autotools: Install CMake files as generated by CMake 3.19.6 + so that users with "find_package(expat [..] CONFIG [..])" + are served on distributions that are *not* using the CMake + build system inside for libexpat packaging + #436 #437 Autotools: Drop obsolescent macro AC_HEADER_STDC + #450 #452 Autotools: Resolve use of obsolete macro AC_CONFIG_HEADER + #441 Address compiler warnings + #443 Version info bumped from 7:12:6 to 8:0:7 + due to addition of error code XML_ERROR_NO_BUFFER + (see https://verbump.de/ for what these numbers do) + + Infrastructure: + #435 #446 Replace Travis CI by GitHub Actions + + Special thanks to: + Alexander Richardson + Oleksandr Popovych + Thomas Beutlich + Tim Bray + and + Clang LeakSan, Clang 11 UBSan and the Clang team + Release 2.2.10 Sat October 3 2020 Bug fixes: #390 #395 #398 Fix undefined behavior during parsing caused by @@ -46,7 +95,7 @@ Release 2.2.10 Sat October 3 2020 #354 #355 .. #356 #412 Address compiler warnings #368 #369 Address pngcheck warnings with doc/*.png images - Version info bumped from 7:11:6 to 7:12:6 + #425 Version info bumped from 7:11:6 to 7:12:6 Special thanks to: asavah diff --git a/lib/libexpat/README.md b/lib/libexpat/README.md index 428a11ab245..6e4b422673a 100644 --- a/lib/libexpat/README.md +++ b/lib/libexpat/README.md @@ -1,9 +1,9 @@ -[![Travis CI Build Status](https://travis-ci.org/libexpat/libexpat.svg?branch=master)](https://travis-ci.org/libexpat/libexpat) +[![Run Linux Travis CI tasks](https://github.com/libexpat/libexpat/actions/workflows/linux.yml/badge.svg)](https://github.com/libexpat/libexpat/actions/workflows/linux.yml) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/libexpat/libexpat?svg=true)](https://ci.appveyor.com/project/libexpat/libexpat) [![Packaging status](https://repology.org/badge/tiny-repos/expat.svg)](https://repology.org/metapackage/expat/versions) -# Expat, Release 2.2.10 +# Expat, Release 2.3.0 This is Expat, a C library for parsing XML, started by [James Clark](https://en.wikipedia.org/wiki/James_Clark_(programmer)) in 1997. @@ -14,13 +14,14 @@ document being parsed. A start tag is an example of the kind of structures for which you may register handlers. Expat supports the following compilers: + - GNU GCC >=4.5 - LLVM Clang >=3.5 -- Microsoft Visual Studio >=9.0/2008 +- Microsoft Visual Studio >=15.0/2017 (rolling `${today} minus 5 years`) Windows users can use the -[`expat_win32` package](https://sourceforge.net/projects/expat/files/expat_win32/), -which includes both precompiled libraries and executables, and source code for +[`expat-win32bin-*.*.*.exe` installer download](https://github.com/libexpat/libexpat/releases), +which includes both pre-compiled libraries and executables, and source code for developers. Expat is [free software](https://www.gnu.org/philosophy/free-sw.en.html). @@ -30,6 +31,62 @@ contained in the file distributed with this package. This license is the same as the MIT/X Consortium license. + +## Using libexpat in your CMake-Based Project + +There are two ways of using libexpat with CMake: + +### a) Module Mode + +This approach leverages CMake's own [module `FindEXPAT`](https://cmake.org/cmake/help/latest/module/FindEXPAT.html). + +Notice the uppercase `EXPAT` in the following example: + +```cmake +cmake_minimum_required(VERSION 3.0) + +project(hello VERSION 1.0.0) + +find_package(EXPAT 2.2.8 MODULE REQUIRED) + +add_executable(hello + hello.c +) + +if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.10") + target_link_libraries(hello PUBLIC EXPAT::EXPAT) +else() + target_include_directories(hello PRIVATE ${EXPAT_INCLUDE_DIRS}) + target_link_libraries(hello PUBLIC ${EXPAT_LIBRARIES}) +endif() +``` + +### b) Config Mode + +This approach requires files from +libexpat >=2.2.8 where packaging uses the CMake build system +or +libexpat >=2.3.0 where packaging uses the GNU Autotools build system. + +Notice the lowercase `expat` in the following example: + +```cmake +cmake_minimum_required(VERSION 3.0) + +project(hello VERSION 1.0.0) + +find_package(expat 2.2.8 CONFIG REQUIRED char dtd ns) + +add_executable(hello + hello.c +) + +target_link_libraries(hello PUBLIC expat::expat) +``` + + +## Buildung from a Git Clone + If you are building Expat from a check-out from the [Git repository](https://github.com/libexpat/libexpat/), you need to run a script that generates the configure script using the @@ -43,6 +100,11 @@ autoconf 2.58 or newer. Run the script like this: Once this has been done, follow the same instructions as for building from a source distribution. + +## Buildung from a Source Distribution + +### a) Building with the configure script (i.e. GNU Autotools) + To build Expat from a source distribution, you first run the configuration shell script in the top level distribution directory: @@ -132,8 +194,14 @@ A reference manual is available in the file `doc/reference.html` in this distribution. -The CMake build system is still *experimental* and will replace the primary +### b) Building with CMake + +The CMake build system is still *experimental* and may replace the primary build system based on GNU Autotools at some point when it is ready. + + +#### Available Options + For an idea of the available (non-advanced) options for building with CMake: ```console diff --git a/lib/libexpat/lib/expat.h b/lib/libexpat/lib/expat.h index cb828db155f..7aa60f31a0a 100644 --- a/lib/libexpat/lib/expat.h +++ b/lib/libexpat/lib/expat.h @@ -115,7 +115,9 @@ enum XML_Error { XML_ERROR_RESERVED_PREFIX_XMLNS, XML_ERROR_RESERVED_NAMESPACE_URI, /* Added in 2.2.1. */ - XML_ERROR_INVALID_ARGUMENT + XML_ERROR_INVALID_ARGUMENT, + /* Added in 2.3.0. */ + XML_ERROR_NO_BUFFER }; enum XML_Content_Type { @@ -513,7 +515,7 @@ typedef struct { Otherwise it must return XML_STATUS_ERROR. If info does not describe a suitable encoding, then the parser will - return an XML_UNKNOWN_ENCODING error. + return an XML_ERROR_UNKNOWN_ENCODING error. */ typedef int(XMLCALL *XML_UnknownEncodingHandler)(void *encodingHandlerData, const XML_Char *name, @@ -1014,8 +1016,8 @@ XML_GetFeatureList(void); See http://semver.org. */ #define XML_MAJOR_VERSION 2 -#define XML_MINOR_VERSION 2 -#define XML_MICRO_VERSION 10 +#define XML_MINOR_VERSION 3 +#define XML_MICRO_VERSION 0 #ifdef __cplusplus } diff --git a/lib/libexpat/lib/siphash.h b/lib/libexpat/lib/siphash.h index bfee65a332f..e5406d7ee9e 100644 --- a/lib/libexpat/lib/siphash.h +++ b/lib/libexpat/lib/siphash.h @@ -11,6 +11,9 @@ * -------------------------------------------------------------------------- * HISTORY: * + * 2020-10-03 (Sebastian Pipping) + * - Drop support for Visual Studio 9.0/2008 and earlier + * * 2019-08-03 (Sebastian Pipping) * - Mark part of sip24_valid as to be excluded from clang-format * - Re-format code using clang-format 9 @@ -96,15 +99,7 @@ #define SIPHASH_H #include <stddef.h> /* size_t */ - -#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1600) -/* For vs2003/7.1 up to vs2008/9.0; _MSC_VER 1600 is vs2010/10.0 */ -typedef unsigned __int8 uint8_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int64 uint64_t; -#else -# include <stdint.h> /* uint64_t uint32_t uint8_t */ -#endif +#include <stdint.h> /* uint64_t uint32_t uint8_t */ /* * Workaround to not require a C++11 compiler for using ULL suffix diff --git a/lib/libexpat/lib/xmlparse.c b/lib/libexpat/lib/xmlparse.c index b6e723afa09..f71b60ef4fa 100644 --- a/lib/libexpat/lib/xmlparse.c +++ b/lib/libexpat/lib/xmlparse.c @@ -1,4 +1,4 @@ -/* 5cd169f2942b85c05e0b1b96f9990f91ac3d07e470ad7ce906ac8590c8ed4f35 (2.2.10+) +/* d667b5f8e56e24fdfaf5e38596d419d924a9fadceb987d81d5613ecb7ca51b0e (2.3.0+) __ __ _ ___\ \/ /_ __ __ _| |_ / _ \\ /| '_ \ / _` | __| @@ -47,17 +47,7 @@ #include <limits.h> /* UINT_MAX */ #include <stdio.h> /* fprintf */ #include <stdlib.h> /* getenv, rand_s */ - -#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1600) -/* vs2008/9.0 and earlier lack stdint.h; _MSC_VER 1600 is vs2010/10.0 */ -# if defined(_WIN64) -typedef unsigned __int64 uintptr_t; -# else -typedef unsigned __int32 uintptr_t; -# endif -#else -# include <stdint.h> /* uintptr_t */ -#endif +#include <stdint.h> /* uintptr_t */ #ifdef _WIN32 # define getpid GetCurrentProcessId @@ -1697,6 +1687,12 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal) { parser->m_errorCode = XML_ERROR_FINISHED; return XML_STATUS_ERROR; case XML_INITIALIZED: + /* Has someone called XML_GetBuffer successfully before? */ + if (! parser->m_bufferPtr) { + parser->m_errorCode = XML_ERROR_NO_BUFFER; + return XML_STATUS_ERROR; + } + if (parser->m_parentParser == NULL && ! startParsing(parser)) { parser->m_errorCode = XML_ERROR_NO_MEMORY; return XML_STATUS_ERROR; @@ -2141,6 +2137,10 @@ XML_ErrorString(enum XML_Error code) { /* Added in 2.2.5. */ case XML_ERROR_INVALID_ARGUMENT: /* Constant added in 2.2.1, already */ return XML_L("invalid argument"); + /* Added in 2.3.0. */ + case XML_ERROR_NO_BUFFER: + return XML_L( + "a successful prior call to function XML_GetBuffer is required"); } return NULL; } diff --git a/lib/libexpat/lib/xmltok.c b/lib/libexpat/lib/xmltok.c index c4f9897f7dc..58dce9091cc 100644 --- a/lib/libexpat/lib/xmltok.c +++ b/lib/libexpat/lib/xmltok.c @@ -32,15 +32,7 @@ #include <stddef.h> #include <string.h> /* memcpy */ - -#if defined(_MSC_VER) && (_MSC_VER <= 1700) -/* for vs2012/11.0/1700 and earlier Visual Studio compilers */ -# define bool int -# define false 0 -# define true 1 -#else -# include <stdbool.h> -#endif +#include <stdbool.h> #ifdef _WIN32 # include "winconfig.h" diff --git a/lib/libexpat/shlib_version b/lib/libexpat/shlib_version index 56246d02b24..262f3bc13b6 100644 --- a/lib/libexpat/shlib_version +++ b/lib/libexpat/shlib_version @@ -1,2 +1,2 @@ -major=12 +major=13 minor=0 diff --git a/lib/libexpat/tests/minicheck.c b/lib/libexpat/tests/minicheck.c index a5a1efb159f..ab0c35fd609 100644 --- a/lib/libexpat/tests/minicheck.c +++ b/lib/libexpat/tests/minicheck.c @@ -141,11 +141,18 @@ _check_set_test_info(char const *function, char const *filename, int lineno) { } static void -add_failure(SRunner *runner, int verbosity) { - runner->nfailures++; +handle_success(int verbosity) { if (verbosity >= CK_VERBOSE) { - printf("%s:%d: %s\n", _check_current_filename, _check_current_lineno, - _check_current_function); + printf("PASS: %s\n", _check_current_function); + } +} + +static void +handle_failure(SRunner *runner, int verbosity, const char *phase_info) { + runner->nfailures++; + if (verbosity != CK_SILENT) { + printf("FAIL: %s (%s at %s:%d)\n", _check_current_function, phase_info, + _check_current_filename, _check_current_lineno); } } @@ -164,14 +171,14 @@ srunner_run_all(SRunner *runner, int verbosity) { if (tc->setup != NULL) { /* setup */ if (setjmp(env)) { - add_failure(runner, verbosity); + handle_failure(runner, verbosity, "during setup"); continue; } tc->setup(); } /* test */ if (setjmp(env)) { - add_failure(runner, verbosity); + handle_failure(runner, verbosity, "during actual test"); continue; } (tc->tests[i])(); @@ -179,15 +186,17 @@ srunner_run_all(SRunner *runner, int verbosity) { /* teardown */ if (tc->teardown != NULL) { if (setjmp(env)) { - add_failure(runner, verbosity); + handle_failure(runner, verbosity, "during teardown"); continue; } tc->teardown(); } + + handle_success(verbosity); } tc = tc->next_tcase; } - if (verbosity) { + if (verbosity != CK_SILENT) { int passed = runner->nchecks - runner->nfailures; double percentage = ((double)passed) / runner->nchecks; int display = (int)(percentage * 100); @@ -203,8 +212,8 @@ _fail_unless(int condition, const char *file, int line, const char *msg) { it is. */ UNUSED_P(condition); - UNUSED_P(file); - UNUSED_P(line); + _check_current_filename = file; + _check_current_lineno = line; if (msg != NULL) { const int has_newline = (msg[strlen(msg) - 1] == '\n'); fprintf(stderr, "ERROR: %s%s", msg, has_newline ? "" : "\n"); diff --git a/lib/libexpat/tests/runtests.c b/lib/libexpat/tests/runtests.c index 2490d86b9ab..91ab4f211b5 100644 --- a/lib/libexpat/tests/runtests.c +++ b/lib/libexpat/tests/runtests.c @@ -45,28 +45,10 @@ #include <stddef.h> /* ptrdiff_t */ #include <ctype.h> #include <limits.h> - -#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1600) -/* For vs2003/7.1 up to vs2008/9.0; _MSC_VER 1600 is vs2010/10.0 */ -# if defined(_WIN64) -typedef __int64 intptr_t; -# else -typedef __int32 intptr_t; -# endif -typedef unsigned __int64 uint64_t; -#else -# include <stdint.h> /* intptr_t uint64_t */ -#endif +#include <stdint.h> /* intptr_t uint64_t */ #if ! defined(__cplusplus) -# if defined(_MSC_VER) && (_MSC_VER <= 1700) -/* for vs2012/11.0/1700 and earlier Visual Studio compilers */ -# define bool int -# define false 0 -# define true 1 -# else -# include <stdbool.h> -# endif +# include <stdbool.h> #endif #include "expat.h" @@ -1779,7 +1761,7 @@ START_TEST(test_not_standalone_handler_accept) { XML_SetNotStandaloneHandler(g_parser, accept_not_standalone_handler); run_ext_character_check(text, &test_data, XCS("")); - /* Repeat wtihout the external entity handler */ + /* Repeat without the external entity handler */ XML_ParserReset(g_parser, NULL); XML_SetNotStandaloneHandler(g_parser, accept_not_standalone_handler); run_character_check(text, XCS("")); @@ -7365,7 +7347,7 @@ START_TEST(test_misc_version) { fail("Version mismatch"); #if ! defined(XML_UNICODE) || defined(XML_UNICODE_WCHAR_T) - if (xcstrcmp(version_text, XCS("expat_2.2.10"))) /* needs bump on releases */ + if (xcstrcmp(version_text, XCS("expat_2.3.0"))) /* needs bump on releases */ fail("XML_*_VERSION in expat.h out of sync?\n"); #else /* If we have XML_UNICODE defined but not XML_UNICODE_WCHAR_T @@ -9851,6 +9833,15 @@ START_TEST(test_nsalloc_parse_buffer) { /* Try a parse before the start of the world */ /* (Exercises new code path) */ + if (XML_ParseBuffer(g_parser, 0, XML_FALSE) != XML_STATUS_ERROR) + fail("Pre-init XML_ParseBuffer not faulted"); + if (XML_GetErrorCode(g_parser) != XML_ERROR_NO_BUFFER) + fail("Pre-init XML_ParseBuffer faulted for wrong reason"); + + buffer = XML_GetBuffer(g_parser, 1 /* any small number greater than 0 */); + if (buffer == NULL) + fail("Could not acquire parse buffer"); + allocation_count = 0; if (XML_ParseBuffer(g_parser, 0, XML_FALSE) != XML_STATUS_ERROR) fail("Pre-init XML_ParseBuffer not faulted"); |