| Age | Commit message (Collapse) | Author | Files | Lines |
|
plist_set_date_val stores val = sec + usec / 1000000, but
plist_get_date_val splits it with a truncating cast and fabs():
*sec = (int32_t)val;
val = fabs((val - (int64_t)val) * 1000000);
*usec = (int32_t)val;
Two results are wrong. The product is truncated, so set(5, 6) reads
back as (5, 5) - 29.3% of round trips over sec in [0, 3] come back a
microsecond short. And for a negative value, truncation toward zero
plus fabs() give a pair that does not denote the same instant:
set(-3, 250000) stores -2.75 and reads back as (-2, 750000), which the
setter would store as -1.25. Every round trip with sec < 0 and
usec != 0 is wrong.
(int32_t)val is also undefined when the stored value is outside the
int32_t range.
Round the seconds down, round the fraction to microseconds carrying
1000000 into the seconds, and clamp the seconds before converting, so
sec + usec / 1000000 == val to the microsecond with 0 <= usec <
1000000 - the convention the setter uses.
Add test/date_val.c covering fixed cases and a sweep over sec in
[-2, 2]. It fails on an unmodified tree - set(5, 6), set(-3, 250000)
and set(-1, 1) all come back as different instants - and passes with
this change, with make check at 44/44.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Arn4YaWtcQBDsQuJtyBmFP
|
|
Build small binary plists in memory and check that arrays and dicts
parse correctly with 1, 2 and 3 byte object references, and that
strings, extended size markers and array/dict references extending
beyond the object data area into the offset table are rejected.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
Free the plist created for the test before exiting, which fixes a leak
reported by LeakSanitizer.
Co-authored-by: bg0d-droid <81825610+bg0d-droid@users.noreply.github.com>
|
|
|
|
|
|
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>
|
|
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.
|
|
|
|
Otherwise test fail with error [: -neq: binary operator expected
Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com>
|
|
Without the change tests ran in parallel occasionally clobber outputs of
one another and fail as:
$ make check -j16 VERBOSE=y
...
FAIL: huge
==========
Converting
File ../test/data/5.plist is open
PList XML parsing succeeded
PList BIN writing succeeded
PList BIN parsing succeeded
PList XML writing succeeded
Size of input and output is different
Input size : 4292380
Output size : 4305301
Comparing
PList parsing failed
FAIL huge.test (exit status: 3)
Closes: https://github.com/libimobiledevice/libplist/issues/234#issuecomment-1743820556
|
|
|
|
|
|
|
|
plist_read_from_file() is a convenience function that will open a
given file, checks its size, allocates a buffer large enough to
hold the full contents, and reads from file to fill the buffer.
Then, it calls plist_from_memory() to convert the data to plist
format.
A (breaking) change had to be made so that plist_from_memory() will
also return the parsed format in its 4th argument (if non-NULL).
|
|
This makes the code more readable. Obviously all the code that uses it
is also updated.
|
|
This properly supports getting and setting signed or unsigned integer values.
Also, a new helper function plist_int_val_is_negative() was added to determine if
a given #PLIST_INT node has a negative value or not.
The old type PLIST_UINT is defined as a macro with the value of PLIST_INT for
backwards compatibility.
This commit also adds int vs. uint support to the C++ interface, and the python
bindings in a hopefully useful way.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string as input
|
|
|
|
|
|
|
|
[clang-tidy] Found with readability-else-after-return
Signed-off-by: Rosen Penev <rosenp@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Apart from testing the actual integer signed vs. unsigned value storage
and conversion, this test will check that the binary plist optimization
is not re-using existing values. Basically it will test the fix that
was introduced with commit acd226d1f71a78dd23b47a9a5c4ca8cf8068d509.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|