Commit graph

3737 commits

Author SHA1 Message Date
Sebastian Pipping
9411ac625b tests: Use NAN and INFINITY of C99 and C++11
Effectively reverts commit f6f5d9bb4c.
2023-11-07 14:22:31 +01:00
Sebastian Pipping
8a6c61de4a lib: Add XML_GE to XML_GetFeatureList and XML_FeatureEnum
Co-authored-by: Snild Dolkow <snild@sony.com>
2023-11-07 13:00:42 +01:00
clang-format
ac14808b26 Mass-apply clang-format 17.0.3 using ./apply-clang-format.sh 2023-11-07 13:00:42 +01:00
Sebastian Pipping
55fecd6aa4 Drop redundant "XML_GE == 1" guards
These are redundant because further out there is a guard
for "XML_GE == 1" already.  In the visual world, the pattern
is this:

> #if XML_GE == 1
> [..]
> #  if XML_GE == 1
> [..]
> #  endif
> [..]
> #endif

Spotted by Snild Dolkow, thanks!

Co-authored-by: Snild Dolkow <snild@sony.com>
2023-11-07 13:00:42 +01:00
Sebastian Pipping
caa2719863 Simplify "defined(XML_DTD) || XML_GE == 1" to "XML_GE == 1" 2023-11-07 13:00:42 +01:00
Sebastian Pipping
2848dc4e70 Simplify "! defined(XML_DTD) && XML_GE == 0" to "XML_GE == 0" 2023-11-07 13:00:42 +01:00
Sebastian Pipping
d269f90975 coverage.sh: Cover XML_DTD undefined (with and without XML_GE) 2023-11-07 13:00:42 +01:00
Sebastian Pipping
cdead241d4 doc/reference.html: Clarify effect of XML_DTD on external entities
Defining XML_DTD emnables support for external parameter(!)
entities.  External general(!) entities have been supported
even with XML_DTD undefined.  (Only now with Expat 2.6.0
defining XML_GE as 0 can take that away.)
2023-11-07 13:00:42 +01:00
Sebastian Pipping
d3f7bbd37b doc/reference.html: Document build time macro XML_GE 2023-11-07 13:00:42 +01:00
Sebastian Pipping
2f18bacfcd tests: Cover and adjust to XML_GE==0 self-references 2023-11-07 13:00:42 +01:00
Sebastian Pipping
2b127c20b2 lib: Make XML_GE==0 use self-references as entity replacement text 2023-11-06 21:02:42 +01:00
Sebastian Pipping
7767efe1aa tests/handlers.c: Make accumulate_entity_decl robust towards value==NULL 2023-11-06 21:02:42 +01:00
Sebastian Pipping
b0975cb73a lib: Fail the build if XML_GE is not set to 1 or 0 2023-11-06 20:43:09 +01:00
Sebastian Pipping
00089ed745 tests: Fix tests for XML_GE==0 + broaden for XML_GE==1 2023-11-06 20:43:09 +01:00
Sebastian Pipping
0f075ec8ec lib|xmlwf|cmake: Extend scope of billion laughs attack protection
.. from "defined(XML_DTD)" to "defined(XML_DTD) || XML_GE==1".
2023-11-06 20:43:09 +01:00
Sebastian Pipping
ed87a47934 configure.ac: Define macro XML_GE as 1 2023-11-06 20:43:09 +01:00
Sebastian Pipping
daa89e42c0 cmake: Introduce option EXPAT_GE to control macro XML_GE 2023-11-06 20:43:09 +01:00
Sebastian Pipping
781269f4a8 win32|cmake: Fix FileVersion and ProductVersion in DLL version info
Before: {'FileVersion': 'VER_FILEVERSION', 'ProductVersion': 'VER_FILEVERSION'}
After: {'FileVersion': '2.5.0.0', 'ProductVersion': '2.5.0.0'}

Thanks to @spookyahell for helpful gist "exe2version_info.py":
https://gist.github.com/spookyahell/b317bdf0712aac5fd37dd79f70bfbe69
2023-11-03 21:55:49 +01:00
Sebastian Pipping
d4e0eeb77b
Merge pull request #771 from SonyMobile/buffer-limit
Grow buffer based on current size
2023-10-26 15:53:18 +02:00
Snild Dolkow
119ae277ab Grow buffer based on current size
Until now, the buffer size to grow to has been calculated based on the
distance from the current parse position to the end of the buffer. This
means that the size of any already-parsed data was not considered,
leading to inconsistent buffer growth.

There was also a special case in XML_Parse() when XML_CONTEXT_BYTES was
zero, where the buffer size would be set to twice the incoming string
length. This patch replaces this with an XML_GetBuffer() call.

Growing the buffer based on its total size makes its growth consistent.

The commit includes a test that checks that we can reach the max buffer
size (usually INT_MAX/2 + 1) regardless of previously parsed content.

GitHub CI couldn't allocate the full 1GiB with MinGW/wine32, though it
works locally with the same compiler and wine version. As a workaround,
the test tries to malloc 1GiB, and reduces `maxbuf` to 512MiB in case
of failure.
2023-10-26 08:21:51 +02:00
Sebastian Pipping
4a4e7cfae6 tests/handlers.h: Drop unused type XmlParseFunction
Last use removed in commit b3d14b0d3c
2023-10-25 22:08:04 +02:00
Snild Dolkow
1222ae34fb tests: Use SINGLE_BYTES in test_nobom_utf16_le
All tests now run one instance where SINGLE_BYTES is equivalent to a
single XML_Parse call. Using SINGLE_BYTES therefore gives more coverage,
as evidenced by the new failure we now have to avoid in the test, until
it can be fixed.
2023-10-25 17:25:48 +02:00
Snild Dolkow
29babedcab tests: Remove EE_PARSE_FULL_BUFFER
All tests now run one instance where SINGLE_BYTES is equivalent to a
single XML_Parse call. There is no longer a need for individual tests
to switch between them.
2023-10-25 17:25:05 +02:00
Snild Dolkow
b3d14b0d3c tests: Remove choice between XML_Parse and SINGLE_BYTES
Since commit 091ba48d ("tests: Run SINGLE_BYTES with no chunking"),
all tests are run an extra time with SINGLE_BYTES set to perform just
a single XML_Parse() call. There is no longer a need for individual
tests to switch between them.
2023-10-25 17:25:00 +02:00
Sebastian Pipping
9e1c41343c
Merge pull request #780 from libexpat/xml-dtd-undefined-fix-ext-parser-create-null-dereference
xmlparse.c: Fix `NULL` pointer dereference in `setContext` via `XML_ExternalEntityParserCreate` for `XML_DTD` undefined
2023-10-24 17:05:31 +02:00
Sebastian Pipping
7b814b8220
Merge pull request #781 from libexpat/tests-move-to-the-right-place
tests/acc_tests.c: Move second BOM accounting test to the right place
2023-10-24 17:02:20 +02:00
Sebastian Pipping
54f1c4595f tests/handlers.c: Drop mistaken unused variable marker 2023-10-23 21:18:04 +02:00
Sebastian Pipping
6e1ddc3b9c tests/acc_tests.c: Move second BOM accounting test to the right place
The test makes use of general entities (not parameter entities)
but was mis-filed under parameter entities.
2023-10-23 20:30:45 +02:00
Sebastian Pipping
4eeaf49262 xmlparse.c: Fix NULL pointer dereference in XML_ExternalEntityParserCreate
.. for context NULL inside function setContext
when macro XML_DTD is not defined at compile time.
2023-10-23 18:14:56 +02:00
Sebastian Pipping
76d60929c2 doc/reference.html: Add HTML anchors to definition of XML_* macros 2023-10-23 15:33:08 +02:00
Sebastian Pipping
a83a941898
Merge pull request #774 from libexpat/tests-rename-fail-unless
tests: Rename fail_unless to assert_true for clarity
2023-10-23 14:46:12 +02:00
clang-format
a392427d3a Mass-apply clang-format 17.0.3 using ./apply-clang-format.sh 2023-10-20 23:49:51 +02:00
Sebastian Pipping
da64791736 tests: Rename fail_unless to assert_true for clarity 2023-10-20 23:41:04 +02:00
Sebastian Pipping
cce19de59f tests: Rename _fail_unless to _assert_true for clarity 2023-10-20 23:24:46 +02:00
Sebastian Pipping
eeab6366b0 tests/memcheck.c: Avoid false positive -Wuse-after-free
Symptom was this compile warning from MinGW GCC 12:
> [..]/expat/tests/memcheck.c: In function ‘tracking_realloc’:
> [..]/expat/tests/memcheck.c:169:25: error: pointer ‘ptr’ may be used after ‘realloc’ [-Werror=use-after-free]
>   169 |       entry->allocation = ptr;
>       |       ~~~~~~~~~~~~~~~~~~^~~~~
> [..]/expat/tests/memcheck.c:166:25: note: call to ‘realloc’ here
>   166 |     entry->allocation = realloc(ptr, size);
>       |                         ^~~~~~~~~~~~~~~~~~

The warning is a false positive since the code was only using ptr
when realloc failed where it is documented that the original pointer is
not freed.

The workaround is to no longer override-and-restore entry->allocation
but to only write to it when realloc was successful.  The original
value was equal to ptr so the result is the same.
2023-10-20 20:19:37 +02:00
Sebastian Pipping
4d475d97d6 doc/xmlwf.xml: Add missing entry on "-g <bytes>" 2023-10-18 16:48:03 +02:00
Sebastian Pipping
1746075001 doc/xmlwf.xml: Add missing entry on -h|--help 2023-10-18 16:48:03 +02:00
Sebastian Pipping
114cb042ae doc/xmlwf.xml: Add --help and --version where missing 2023-10-18 16:48:03 +02:00
Sebastian Pipping
96985a1a07 lib/xmlparse.c: Make clang-format 16.0.6 happy again 2023-10-05 15:44:10 +02:00
Sebastian Pipping
23110a864d Be stricter about macro XML_CONTEXT_BYTES
- Start treating -DXML_CONTEXT_BYTES=0 as "no context"
  rather than "context of size 0".  Was documented as
  "must be set to a positive integer", previously.

- Enforce that macro XML_CONTEXT_BYTES is defined at build time to
  avoid accidental misbuilds lacking context in environments that
  bypass both of Expats official build systems.

- Detect and reject use of negative context size at compile time.
2023-10-05 15:44:10 +02:00
Sebastian Pipping
acbcd0915d
Merge pull request #766 from libexpat/doc-parse-buffer-variables
lib/xmlparse.c: Improve parse buffer variables documentation
2023-10-05 14:50:10 +02:00
Sebastian Pipping
32f64cf174
Merge pull request #762 from libexpat/doc-reference-html-promote-xml-parsebuffer-more
doc/reference.html: Promote function XML_ParseBuffer more
2023-10-05 14:49:29 +02:00
Sebastian Pipping
dd34d0e65c lib/xmlparse.c: Improve parse buffer variables documentation 2023-10-04 22:40:31 +02:00
Sebastian Pipping
ab43d8d116 Make inclusion to expat_config.h consistent
.. and priorize the local build over the system header.
2023-10-04 19:58:28 +02:00
Sebastian Pipping
1d3ee5133e doc/reference.html: Make XML_Parse promote XML_ParseBuffer 2023-10-04 18:01:31 +02:00
Sebastian Pipping
81a705b6ae doc/reference.html: Wrap paragraphs by <p> for function XML_Parse 2023-10-03 23:25:09 +02:00
Sebastian Pipping
c1d4c439a1 docs: Mass-replace "re-use[d]" by "reuse[d]"
Pointed out by codespell.
2023-10-03 21:33:55 +02:00
Sebastian Pipping
1763071577
Merge pull request #761 from libexpat/xmlwf-help-version
xmlwf: Support --help and --version
2023-09-29 17:48:21 +02:00
Sebastian Pipping
92cdc783f1 xmlwf: Get help output alignment back in order 2023-09-29 12:55:17 +02:00
Sebastian Pipping
4c6731ad11 xmlwf: Use XMLWF_EXIT_SUCCESS where missing 2023-09-29 12:55:17 +02:00