Commit graph

4497 commits

Author SHA1 Message Date
Sebastian Pipping
bedbf381b3 Changes: Document #992 2025-03-27 03:31:44 +01:00
Sebastian Pipping
2dc146751a README.md: Add badge for OpenSSF Best Practices 2025-03-27 03:27:04 +01:00
Sebastian Pipping
91ca72e913
Merge pull request #988 from libexpat/dependabot/github_actions/actions/upload-artifact-4.6.2
Some checks failed
Ensure that GNU Autotools and CMake build systems agree / Ensure that GNU Autotools and CMake build systems agree (push) Has been cancelled
Collect test coverage / Collect test coverage (push) Has been cancelled
Upload build to Coverity Scan / Upload build to Coverity Scan (push) Has been cancelled
Run Cppcheck (from macOS Homebrew) / Run Cppcheck (push) Has been cancelled
Run macOS CI tasks / Perform checks (push) Has been cancelled
Enforce clang-format clean code / Enforce clang-format clean code (push) Has been cancelled
Enforce Clang Static Analyzer (scan-build) clean code / Enforce Clang Static Analyzer (scan-build) clean code (push) Has been cancelled
Enforce clang-tidy clean code / Enforce clang-tidy clean code (push) Has been cancelled
Ensure realistic minimum CMake version requirement / Ensure realistic minimum CMake version requirement (push) Has been cancelled
Enforce codespell-clean spelling / Enforce codespell-clean spelling (push) Has been cancelled
Build with Emscripten / Build with Emscripten (push) Has been cancelled
Check expat_config.h.{in,cmake} for regressions / Check expat_config.h.{in,cmake} for regressions (push) Has been cancelled
Run fuzzing regression tests / Run fuzzing regression tests (push) Has been cancelled
Run Linux CI tasks / Perform checks (push) Has been cancelled
Build with musl / Build with musl (push) Has been cancelled
Ensure well-formed and valid XML / Ensure well-formed and valid XML (push) Has been cancelled
Build Windows binaries / Build win32 binaries (push) Has been cancelled
Build Windows binaries / Build win64 binaries (push) Has been cancelled
Build on Windows / Build on Windows (windows-2019, Win32, char) (push) Has been cancelled
Build on Windows / Build on Windows (windows-2022, x64, wchar_t) (push) Has been cancelled
Actions(deps): Bump actions/upload-artifact from 4.6.1 to 4.6.2
2025-03-24 18:02:52 +01:00
dependabot[bot]
9c7609a007
Actions(deps): Bump actions/upload-artifact from 4.6.1 to 4.6.2
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.6.1 to 4.6.2.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](4cec3d8aa0...ea165f8d65)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-24 12:45:06 +00:00
Sebastian Pipping
453c150541
Merge pull request #987 from libexpat/clang-static-analyzer
Make GitHub Actions apply Clang Static Analyzer
2025-03-22 02:30:01 +01:00
Sebastian Pipping
6a56fd6f9e Changes: Document #987 2025-03-22 01:30:36 +01:00
Sebastian Pipping
ad45b4f4e2 Make GitHub Actions apply Clang Static Analyzer 2025-03-22 01:21:50 +01:00
Sebastian Pipping
ec81c552a1
Merge pull request #986 from libexpat/address-frama-c-warning
Address Frama-C warning
2025-03-21 23:49:12 +01:00
Sebastian Pipping
d53df45fd8 Changes: Document #986 2025-03-21 23:07:17 +01:00
Sebastian Pipping
ea3b852acf lib/xmlparse.c: Address warning from frama-c 30.0
The symptom was:
> [variadic:typing] lib/xmlparse.c:8242: Warning:
>   Incorrect type for argument 7. The argument will be cast from unsigned int to int.
2025-03-21 23:02:05 +01:00
Sebastian Pipping
6fd58ad630
Merge pull request #984 from libexpat/issue-983-emscripten-support
Fix `printf` format specifiers for 32bit Emscripten (fixes #983) + cover compilation with 32bit Emscripten in CI
2025-03-17 04:32:05 +01:00
Sebastian Pipping
5c1385f94e Changes: Document #983 #984 2025-03-17 03:49:10 +01:00
Sebastian Pipping
2f6611391e Make GitHub Actions cover compilation with 32bit Emscripten 2025-03-17 03:49:10 +01:00
Sebastian Pipping
41fcb44549 lib/internal.h: Fix printf format specifiers for 32bit mode Emscripten
When compiling with Emscripten 3.1.6, the symptom was:
> [..]
> /usr/bin/emcc  @CMakeFiles/expat.dir/includes_C.rsp -fno-strict-aliasing -fvisibility=hidden -std=c99 -MD -MT CMakeFiles/expat.dir/lib/xmlparse.c.o -MF CMakeFiles/expat.dir/lib/xmlparse.c.o.d -o CMakeFiles/expat.dir/lib/xmlparse.c.o -c /libexpat/expat/lib/xmlparse.c
> /libexpat/expat/lib/xmlparse.c:8132:11: warning: format specifies type 'int' but the argument has type 'ptrdiff_t' (aka 'long') [-Wformat]
>           bytesMore, (account == XML_ACCOUNT_DIRECT) ? "DIR" : "EXP",
>           ^~~~~~~~~
> 1 warning generated.
> [..]
> /usr/bin/emcc -DXML_TESTING @CMakeFiles/runtests.dir/includes_C.rsp -fno-strict-aliasing -fvisibility=hidden -std=c99 -MD -MT CMakeFiles/runtests.dir/tests/acc_tests.c.o -MF CMakeFiles/runtests.dir/tests/acc_tests.c.o.d -o CMakeFiles/runtests.dir/tests/acc_tests.c.o -c /libexpat/expat/tests/acc_tests.c
> /libexpat/expat/tests/acc_tests.c:279:11: warning: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Wformat]
>           u + 1, countCases, expectedCountBytesDirect, actualCountBytesDirect);
>           ^~~~~
> /libexpat/expat/tests/acc_tests.c:279:18: warning: format specifies type 'unsigned int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
>           u + 1, countCases, expectedCountBytesDirect, actualCountBytesDirect);
>                  ^~~~~~~~~~
> /libexpat/expat/tests/acc_tests.c:288:11: warning: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Wformat]
>           u + 1, countCases, expectedCountBytesIndirect,
>           ^~~~~
> /libexpat/expat/tests/acc_tests.c:288:18: warning: format specifies type 'unsigned int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
>           u + 1, countCases, expectedCountBytesIndirect,
>                  ^~~~~~~~~~
> 4 warnings generated.
> [..]
> /usr/bin/emcc -DXML_TESTING @CMakeFiles/runtests.dir/includes_C.rsp -fno-strict-aliasing -fvisibility=hidden -std=c99 -MD -MT CMakeFiles/runtests.dir/lib/xmlparse.c.o -MF CMakeFiles/runtests.dir/lib/xmlparse.c.o.d -o CMakeFiles/runtests.dir/lib/xmlparse.c.o -c /libexpat/expat/lib/xmlparse.c
> /libexpat/expat/lib/xmlparse.c:8132:11: warning: format specifies type 'int' but the argument has type 'ptrdiff_t' (aka 'long') [-Wformat]
>           bytesMore, (account == XML_ACCOUNT_DIRECT) ? "DIR" : "EXP",
>           ^~~~~~~~~
> 1 warning generated.
> [..]
> /usr/bin/em++ -DXML_TESTING @CMakeFiles/runtests_cxx.dir/includes_CXX.rsp -fno-strict-aliasing -fvisibility=hidden -std=c++11 -MD -MT CMakeFiles/runtests_cxx.dir/tests/acc_tests_cxx.cpp.o -MF CMakeFiles/runtests_cxx.dir/tests/acc_tests_cxx.cpp.o.d -o CMakeFiles/runtests_cxx.dir/tests/acc_tests_cxx.cpp.o -c /libexpat/expat/tests/acc_tests_cxx.cpp
> In file included from /libexpat/expat/tests/acc_tests_cxx.cpp:32:
> /libexpat/expat/tests/acc_tests.c:279:11: warning: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Wformat]
>           u + 1, countCases, expectedCountBytesDirect, actualCountBytesDirect);
>           ^~~~~
> /libexpat/expat/tests/acc_tests.c:279:18: warning: format specifies type 'unsigned int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
>           u + 1, countCases, expectedCountBytesDirect, actualCountBytesDirect);
>                  ^~~~~~~~~~
> /libexpat/expat/tests/acc_tests.c:288:11: warning: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Wformat]
>           u + 1, countCases, expectedCountBytesIndirect,
>           ^~~~~
> /libexpat/expat/tests/acc_tests.c:288:18: warning: format specifies type 'unsigned int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
>           u + 1, countCases, expectedCountBytesIndirect,
>                  ^~~~~~~~~~
> 4 warnings generated.
> [..]
> /usr/bin/emcc -DXML_TESTING @CMakeFiles/runtests_cxx.dir/includes_C.rsp -fno-strict-aliasing -fvisibility=hidden -std=c99 -MD -MT CMakeFiles/runtests_cxx.dir/lib/xmlparse.c.o -MF CMakeFiles/runtests_cxx.dir/lib/xmlparse.c.o.d -o CMakeFiles/runtests_cxx.dir/lib/xmlparse.c.o -c /libexpat/expat/lib/xmlparse.c
> /libexpat/expat/lib/xmlparse.c:8132:11: warning: format specifies type 'int' but the argument has type 'ptrdiff_t' (aka 'long') [-Wformat]
>           bytesMore, (account == XML_ACCOUNT_DIRECT) ? "DIR" : "EXP",
>           ^~~~~~~~~
> 1 warning generated.
2025-03-17 03:49:10 +01:00
Sebastian Pipping
9f52e11c2c
Merge pull request #981 from libexpat/musl-ci
Make GitHub Actions cover compilation with musl
2025-03-16 02:08:12 +01:00
Sebastian Pipping
26de2e1daa Changes: Document #981 2025-03-16 00:48:01 +01:00
Sebastian Pipping
f0394e734a Make GitHub Actions cover compilation with musl 2025-03-16 00:48:01 +01:00
Sebastian Pipping
6579a00ec3
Merge pull request #978 from libexpat/tests-benchmark-resolve-double-close
`tests/benchmark`: Resolve mistaken double close
2025-03-15 16:03:13 +01:00
Sebastian Pipping
ac8a0e8f04 tests/benchmark: Resolve mistaken double close
From "man fdopen":
> The file descriptor is not dup'ed, and will be closed
> when the stream created by fdopen() is closed.
2025-03-15 01:38:13 +01:00
Sebastian Pipping
fb4faf6573
Merge pull request #977 from libexpat/issue-976-automake-add-missing-files
Integrate missing fuzzer files with Automake (fixes #976)
2025-03-15 01:01:53 +01:00
Sebastian Pipping
fec0d8cdab Changes: Document #977 2025-03-14 23:22:31 +01:00
Sebastian Pipping
991a5de397 fuzzing.yml: Re-group artifact naming
This grouping better suits a human interested in one particular fuzzer.
2025-03-14 23:22:31 +01:00
Sebastian Pipping
1c24499c1b fuzzing.yml: Ensure that "make dist" includes all files for fuzzing 2025-03-14 23:15:24 +01:00
Sebastian Pipping
7959225d05 Makefile.am: Add missing files for xml_lpm_fuzzer 2025-03-14 23:15:24 +01:00
Sebastian Pipping
6d4ffe856d
Merge pull request #975 from libexpat/issue-974-prepare-release
Prepare release 2.7.0 (part of #974, ETA 2024-13-13)
2025-03-13 21:59:00 +01:00
Sebastian Pipping
2ae4c8afd3 Sync file headers 2025-03-13 20:41:33 +01:00
Sebastian Pipping
fd640c0915 Set release date for 2.7.0 2025-03-13 20:41:33 +01:00
Sebastian Pipping
0a6cbff62c Bump version to 2.7.0 2025-03-13 20:41:33 +01:00
Sebastian Pipping
70b24434c7 Bump version info from 11:0:10 to 11:1:10
See https://verbump.de/ for what these numbers do
2025-03-13 20:41:33 +01:00
Sebastian Pipping
f7611735f9 Changes: Document changes in release Expat 2.7.0 2025-03-13 20:41:33 +01:00
Sebastian Pipping
99529768b4
Merge pull request #973 from berkayurun/issue-893-fix-cve-2024-8176
[CVE-2024-8176] Resolve the recursion during entity processing to prevent stack overflow (fixes #893)
2025-03-13 17:21:23 +01:00
Sebastian Pipping
5e8abaf557 Changes: Document CVE-2024-8176 2025-03-13 14:01:31 +01:00
Sebastian Pipping
bbd413a808 Sync file headers 2025-03-13 14:01:31 +01:00
Berkay Eren Ürün
eb53088cd5 tests: Cover missing elements after internal entity reference 2025-03-13 14:01:31 +01:00
Berkay Eren Ürün
f2edeaaece Delete the check that prevents reentry
The early return in case of zero open internal entities and matching
end/nextPtr pointers cause the parser to miss XML_ERROR_NO_ELEMENTS
error.

The reason is that the internalEntityProcessor does not set the
m_reenter flag in such a case, which results in skipping the
prologProcessor or contentProcessor depending on wheter is_param is set
or not. However, this last skipped call to mentioned processors can
detect the non-existence of elements when some are expected.
2025-03-13 14:01:31 +01:00
Berkay Eren Ürün
7b9758517b Remove unnecessary triggerReenter calls
callStoreEntityValue and storeAttributeValue call triggerReenter just
before continuing with their main loop. This call does not have any
use for the these functions as the continuity of their loop is already
achieved by the continue key word.

Only side effect these triggerReenter calls bring is that they cause a
return to the the callProcessor, only to reenter to the same point again,
wasting some time.

This commit removes these unnecessary calls.
2025-03-13 14:01:31 +01:00
Berkay Eren Ürün
c25f0cef93 Handle unreachable return locations
At some points we check m_reenter flag for return. However this flag can
never be true at these points. Therefore body of the check is never
executed. This commit excludes the body from test coverage, removes the
nextPtr update (since we faced an error, no need to update it) and
lastly makes them return XML_ERROR_UNEXPECTED_STATE as a safety net.
2025-03-13 14:01:31 +01:00
Berkay Eren Ürün
e41a398e3f Remove unnecessary checks before entity removal
After the commit "Fix entity debug order", the interaction with the open
entity lists has been changed.

Before the commit, during processing of an entity, if an inner entity was
found, it was pushed to the head of the list. This made the entity we were
processing the second in the list. So, in order the remove this entity,
we either remove the head or the second element, depending on if an inner
entity is found during processing.

After the commit, since we delay the removal of entities until their
inner entity references are resolved, the entity we want to remove will
always be on the head of the list. Thus the removal of the check.
2025-03-13 14:01:31 +01:00
Sebastian Pipping
d0e04b3b75 tests: Cover free'ing of all three open entity lists by XML_ParserReset
.. without taking away coverage from XML_ParserFree
2025-03-13 14:01:31 +01:00
Berkay Eren Ürün
92f66bb50e Fix up on commit "Add next pointer to appendAttributeValue"
Remove unrequired nextPtr assignments
2025-03-13 14:01:31 +01:00
Berkay Eren Ürün
66b695f150 Increase coverage for parameter entity refs in doProlog 2025-03-13 14:01:31 +01:00
Berkay Eren Ürün
495fb53b16 Fix infinite loop with indirectly recursive entities
Detection of recursive entity references are currently failing because
we process and close entities before their inner references are
processed. Since the detection works by checking wheter the referenced
entity is already open, this early close leads to wrong results. This
commit delays closing entities until their inner entities are processed
and closed. This is achieved by postponing the unsetting of the open
flag and using a new hasMore flag to check if the entity has more
elements to process.
2025-03-13 14:01:31 +01:00
Berkay Eren Ürün
c20ce3aaa3 Fix entity debug order
The fix for entity processing changes the order of opening and closing
of entities. The reason is the new iterative approach that closes
and removes entities as soon as they are fully processed, unlike
the recursive approach that, as a side effect of the recursion, waits
the inner entities before closing and removal.

This commit delays the removal and the call to entityTrackingOnClose
until the current entities inner entities are processed, which in turn
allows us to have the correct debug order again.
2025-03-13 14:01:31 +01:00
Berkay Eren Ürün
16a3b9d356 Merge entity processors 2025-03-13 14:01:31 +01:00
Berkay Eren Ürün
e15cdd6c1f Add test case for nested entities with delayed interpretation 2025-03-13 14:01:31 +01:00
Berkay Eren Ürün
fabae41d28 Fix storeEntityValue recursion 2025-03-13 14:01:31 +01:00
Berkay Eren Ürün
bf97ac5081 Add next pointer to storeEntityValue
This commit introduces a new nextPtr parameter to storeEntityValue.
After finishing its execution, storeEntityValue function sets this
parameter in way that it points to the next token to process.

This is useful when we want to leave and reenter storeEntityValue during
its execution since nextPtr will point where we left.

This commit is base to the following commit.
2025-03-13 14:01:31 +01:00
Berkay Eren Ürün
00fda3c598 Add test case for unbounded entity recursion in attributes 2025-03-13 14:01:31 +01:00
Berkay Eren Ürün
da10ca2328 Break cyclic appendAttributeValue recursion
During processing attributes with entity references,
appendAttributeValue can reach high recursion depths that can lead to
a crash.

This commit switches the processing to an iterative approach similar to
the fix for internal entity processing. A new m_openAttributeEntities
list is introduced to keep track of entity references that need
processing. When a new entity reference is detected, instead of calling
appendAttributeValue recursively, the entity will be added to open
entities list and the execution will return to storeAttributeValue,
where newly added entity will be handled. After the entity processing
is done, appendAttributeValue will be called by using the next token.
2025-03-13 14:01:31 +01:00
Berkay Eren Ürün
74308916d9 Add next pointer to appendAttributeValue
This commits extends appendAttributeValue by introducing a new parameter
that will be set to the next token to process.

Having such a parameter allows us to reenter the function after an exit
and continue from the last token pointed by the pointer.
2025-03-13 14:01:31 +01:00