Merge upstream changes #1

Open
suprstarrd wants to merge 118 commits from mirror/libplist:master into master
Owner
No description provided.
Credit to OSS-Fuzz
This matches what the actual sources do.  Clang 16 and GCC 14
no longer support converting ints to pointers implicitly, so the
configure probe always fails with these compilers.
Actually we are using a slightly modified one that removes the
`Table of Contents` section and replaces it with the doxygen-compatible
`[TOC]` to auto-generate a TOC that has working links.
This makes it more obvious that it is arbitrary data and not necessarily
a string value.
This reverts commit a91f5740d1.
This prevents a bug class where we bswap things when __LITTLE_ENDIAN__ is not defined.
Almost all modern systems are little endian, so detecting __BIG_ENDIAN__ is a better strategy.
Credit to @Anza2001
Otherwise the internal assertion will trigger since the incorrect
size will be checked against.

Thanks to @michaelwright235, @guyingzhao, and others for pointing this out!
These functions work with int64_t values representing a UNIX timestamp instead
of using the 'MAC epoch'. They should be used instead of plist_new_date,
plist_get_date_val, and plist_set_date_val, which are now marked deprecated
and might be removed in a future version of libplist.
plist_date_val_compare calls plist_get_date_val which is now marked
deprecated. To avoid compiler warnings during build, we use the underlying
implementation directly instead of calling the function to work around it.
Updated the Integer(const PList::Integer&) constructor to free the existing plist node and copy the node from the input object, ensuring correct initialization.
Given the fact that timegm64 is only invoked with a valid pointer,
this should never trigger.
Thanks to @ylwango613 for pointing this out!
Thanks to @ylwango613 for reporting
Thanks to @ylwango613 for reporting.
Even though this is weird, the DTD allows it. This commit will also make
the XML output write `<key/>` and `<string/>` instead of `<key></key>` and `<string></string>`
in case of empty key/string node.
Otherwise test fail with error [: -neq: binary operator expected

Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com>
Credit to OSS-Fuzz
Ensure plist_data_compare safely handles NULL inputs by normalizing
NULL data to empty values and avoiding invalid dereferences.
Thanks to @LkkkLxy for pointing out the issue.
Thanks to @unbengable12 for reporting. Addresses #288, #289, #290, #291, and #292.
Credit to @LkkkLxy for reporting (#276).

libplist nodes are owned by exactly one container. Inserting the same
plist_t into multiple dicts or arrays corrupts the tree structure and
leads to use-after-free crashes during traversal or plist_free().

Add explicit parent checks to dict and array insertion APIs to reject
nodes that already belong to another container. In debug builds, this
fails loudly via assert() and optional diagnostics; in release builds,
the operation safely no-ops.

Callers that need to reuse values must create a copy using plist_copy()
or explicitly detach the node before reinserting it.
Credit to @LkkkLxy. Addresses #277.
Use size_t for token start/end offsets instead of int, replace the -1
sentinel with SIZE_MAX, and add a defensive guard against offset
wraparound. This prevents overflow when parsing very large JSON inputs.

This addresses issue #282.

Credit to @ylwango613 for repporting.
- Treat input as unsigned bytes
- Correct UTF-8 bit decoding for 2/3/4-byte sequences
- Add overlong, surrogate, and range checks
- Enforce lead/continuation byte constraints

This addresses issue #283.

Credit to @hgarrereyn for reporting.
Fixes #285

Credit to @ylwango613 for reporting.
- Fix numeric character reference parsing
- Enforce exact entity name matching
- Guard against size_t underflow and oversized entities
- Reject invalid Unicode code points
Fixes issue #300

Credit to @jasonmli8
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Credit to @ylwango613
Use explicit key/value stepping, zero-initialize hash lookup key,
and perform length-checked comparisons on NUL-terminated key strings.
Addresses #302.

Credit to @ylwango613.
This removes the necessity for malloc failures and reduces overhead
This change adds stricter validation for numeric and date nodes,
including full-input consumption, overflow/range checks, and rejection
of invalid floating-point values. Whitespace handling is clarified by
explicitly trimming trailing XML whitespace for value nodes.
Ensure node_detach() clears child->parent after removal and
handles missing children lists safely. This makes detached
nodes reusable and allows correct rollback when reinserting
nodes after failed inserts (e.g. depth-limit failures).

Without this, detached nodes could remain logically parented,
causing inconsistent state and preventing reinsertion.
Update plist array and dict mutation helpers to check
return values from node_attach() and node_insert(). This
prevents cache corruption and allows new depth and cycle
checks to be enforced correctly.
Convert plist_free_node() and plist_copy_node() to iterative
implementations. This avoids unbounded recursion and stack
overflow when handling deeply nested plist data, while
preserving existing semantics and caches.
Introduce private iterator structs for plist_array_iter and
plist_dict_iter, and fix *_next_item() to properly advance
iterator state and handle malformed containers safely.
Credit to OSSFuzz
Convert single-entry { "CF$UID" : <integer> } dictionaries to PLIST_UID
nodes when closing a dict in the XML parser.

Refactor node cleanup logic:
- Split plist_free_data() into internal _plist_free_data()
- Introduce plist_free_children() to release child nodes separately
- Update plist_set_element_val() to free children before changing
  container node types
- Ensure PLIST_DICT hashtables do not free values (assert + force
  free_func = NULL)

This avoids in-place container mutation issues and ensures child
nodes and container metadata are released correctly before
changing node type.

Co-authored-by: Sami Kortelainen <sami.kortelainen@piceasoft.com>
Co-authored-by: Nikias Bassen <nikias@gmx.li>
Ensure that XML property lists contain exactly one root value inside the <plist> element and reject any additional value nodes before </plist>.

Add tests covering root value handling and nested CF$UID conversion behavior.

Co-authored-by: Sami Kortelainen <sami.kortelainen@piceasoft.com>
Co-authored-by: Nikias Bassen <nikias@gmx.li>
- Add PLIST_OPT_COERCE option to coerce PLIST_DATE, PLIST_DATA, and PLIST_UID to JSON-compatible types (ISO 8601 strings, Base64 strings, and integers)
- Add plist_to_json_with_options() function to allow passing coercion options (and others)
- Update plist_write_to_string() and plist_write_to_stream() to support coercion option
- Add --coerce flag to plistutil for JSON output
- Create plist2json symlink that automatically enables coercion when invoked
- Use PLIST_OPT_COERCE option to coerce PLIST_BOOLEAN, PLIST_DATE, PLIST_UID, and PLIST_NULL to OpenStep-compatible types (1 or 0, ISO 8601 strings, integers, and 'NULL' string)
- Add plist_to_openstep_with_options() function to allow passing coercion option (and others)
- Update plist_write_to_string() and plist_write_to_stream() accordingly
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u master:mirror-master
git switch mirror-master

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch master
git merge --no-ff mirror-master
git switch mirror-master
git rebase master
git switch master
git merge --ff-only mirror-master
git switch mirror-master
git rebase master
git switch master
git merge --no-ff mirror-master
git switch master
git merge --squash mirror-master
git switch master
git merge --ff-only mirror-master
git switch master
git merge mirror-master
git push origin master
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
SideStore/libplist!1
No description provided.