summaryrefslogtreecommitdiffstats
path: root/src/xplist.c
AgeCommit message (Collapse)AuthorFilesLines
2023-05-21Add explicit casts and fix return type mismatchesGravatar Nikias Bassen1-33/+33
2023-05-13Add space before PRI* macros, some compilers do not like itGravatar Nikias Bassen1-4/+4
2023-05-13Move PLIST_API to the headersGravatar Nikias Bassen1-2/+2
2023-02-07Fix build without --enable-debugGravatar Nikias Bassen1-0/+2
2023-02-07Add function to interface to allow enabling/disabling error/debug output for ↵Gravatar Nikias Bassen1-0/+5
the format parses This makes the `-d` option work in plistutil that wasn't doing anything
2023-02-06libcnary: Updated typedefs of node_t and node_list_t to contain pointerGravatar Nikias Bassen1-6/+5
This makes the code more readable. Obviously all the code that uses it is also updated.
2023-01-19xplist: Add missing newline to debug messageGravatar Nikias Bassen1-1/+1
2023-01-16Rename PLIST_UINT to PLIST_INT and add plist_new_int() and plist_get_int_val()Gravatar Nikias Bassen1-3/+3
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.
2022-02-07xplist: Prevent undefined behavior by not trying to negate INT64_MINGravatar Nikias Bassen1-1/+1
2021-12-23xplist: Add special handling for PLIST_UID parsing from XMLGravatar Nikias Bassen1-5/+14
In XML, PLIST_UID nodes are stored as a dict with a "CF$UID" key and an integer value, so we want to make it a real PLIST_UID node internally.
2021-12-22Add a return value to plist_to_* and plist_from_* functionsGravatar Nikias Bassen1-16/+45
This way it can be easier determined why an import/export operation failed instead of just having a NULL result.
2021-12-19Add support for PLIST_NULL typeGravatar Nikias Bassen1-5/+19
2021-12-19Add new plist_mem_free() functionGravatar Nikias Bassen1-5/+0
Thanks to @azerg for bringing this to my attention. Instead of having multiple (internally identical) plist_*_free() functions, this commit introduces a single plist_mem_free() that can be used to free the memory allocated by plist_to_xml(), plist_to_bin(), plist_get_key_val(), plist_get_string_val(), and plist_get_data_val(). Note: This commit REMOVES plist_to_bin_free() and plist_to_xml_free().
2021-11-08xplist: Better size estimation for PLIST_REAL nodesGravatar Nikias Bassen1-2/+2
2021-06-22[clang-tidy] Remove casts to the same typeGravatar Rosen Penev1-1/+1
Found with google-readability-casting Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-01-25Replace malloc + memset with calloc where appropriateGravatar Rosen Penev1-2/+1
calloc is faster for big allocations. It's also simpler. Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-11-24Add parentheses to macros for better readabilityGravatar Rosen Penev1-1/+1
[clang-tidy] Found with bugprone-macro-parentheses Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-11-24Improve code readability by using explicit != 0 compare when using strncmpGravatar Rosen Penev1-4/+4
[clang-tidy] Found with bugprone-suspicious-string-compare Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-06-03Remove pointless return in void functionsGravatar Rosen Penev1-2/+0
[clang-tidy] Found with readability-redundant-control-flow Signed-off-by: Rosen Penev <rosenp@gmail.com>
2019-11-07xplist: Bail out when '.' is found while checking for ',' in double to ↵Gravatar Nikias Bassen1-0/+2
string conversion
2019-11-07Add plist_to_bin_free() and plist_to_xml_free() functions that free memory ↵Gravatar Nikias Bassen1-0/+5
allocated by plist_to_bin()/plist_to_xml()
2019-11-07xplist: Increase precision when converting PLIST_REAL nodes to XMLGravatar Nikias Bassen1-37/+16
2019-01-21xplist: Fix dtostr() inserting ':' to output string when fractional part ↵Gravatar Nikias Bassen1-2/+15
overflows
2018-12-17xplist: Write base64 directly to output buffer to improve memory usageGravatar Nikias Bassen1-5/+2
Now that we grow the output buffer enough before writing XML output we can just write the base64 encoded data directly to the ouput buffer instead of using a heap buffer that will then be copied to the output buffer. This makes writing XML output more memory efficient (and slightly faster).
2018-12-14xplist: Improve memory usage by estimating output buffer sizeGravatar Nikias Bassen1-2/+127
2018-12-14xplist: Fix writing of empty dict and array nodes to XMLGravatar Nikias Bassen1-8/+6
2018-12-11xplist: Fix segfault caused by recent changes in libcnaryGravatar Nikias Bassen1-1/+1
2018-12-10xplist: Prevent unnecessary reallocations when writing XML outputGravatar Nikias Bassen1-1/+4
2018-12-10Remove node_iterator and operate on node list directly to improve memory usageGravatar Nikias Bassen1-4/+1
2018-09-04xplist: Assert when number of child nodes of PLIST_DICT is not evenGravatar Nikias Bassen1-0/+3
This should only happen due to misuse of the library, e.g. when calling plist_free() on a node that is a value node in a PLIST_DICT without properly removing the dictionary entry (key/value pair) and then calling plist_to_xml() on that dictionary.
2018-07-25xplist: Fix typo in error messageGravatar Bastien Nocera1-1/+1
2017-04-02xplist: Plug another memory leakGravatar Nikias Bassen1-0/+3
Credit to OSS-Fuzz
2017-03-29xplist: Prevent memory leak(s) when parsing failsGravatar Nikias Bassen1-2/+2
Credit to OSS-Fuzz
2017-03-29xplist: Make XML parsing non-recursive to prevent stack overflow on ↵Gravatar Nikias Bassen1-79/+103
deep-structured plists Credit to OSS-Fuzz
2017-02-15xplist: Improve writing of large PLIST_DATA nodes by growing buffer in advanceGravatar Nikias Bassen1-0/+1
Instead of letting the buffer grow by just the amount of bytes currently transformed to base64 - which is basically line by line - we now calculate the size of the output blob in advance and grow the buffer accordingly. This will reduce the amount of reallocs to just one, which is especially important for large data blobs. While this is a general improvement for all platforms, it is on platforms like Windows where realloc() can be REALLY slow; converting a 20mb blob to XML can easily take up to a minute (due to the several hundred thousand calls to realloc()). With this commit, it will be fast again.
2017-02-09xplist: Fix OOB heap buffer read with empty data nodesGravatar Nikias Bassen1-2/+4
Credit to OSS-Fuzz
2017-02-09xplist: Prevent assert when parsing CF$UID dict with invalid value nodeGravatar Nikias Bassen1-0/+5
Credit to OSS-Fuzz
2017-02-08xplist: Use proper variable size for integer from string parsingGravatar Nikias Bassen1-2/+2
2017-02-07xplist: Prevent some more strncmp related OOB readsGravatar Nikias Bassen1-4/+4
2017-02-07xplist: Really fix OOB read when parsing DOCTYPEGravatar Nikias Bassen1-1/+1
2017-02-07xplist: unescape_entities(): Make sure text part buffer is null terminated ↵Gravatar Nikias Bassen1-0/+1
after strncpy
2017-02-07xplist: Fix OOB read when parsing DOCTYPEGravatar Nikias Bassen1-1/+1
2017-02-07xplist: Also fix OOB read in find_char() and find_str() functionsGravatar Nikias Bassen1-0/+8
2017-02-07xplist: Prevent OOB read in two more casesGravatar Nikias Bassen1-0/+10
2017-02-07xplist: Fix OOB read when parsing double quotesGravatar Nikias Bassen1-0/+4
2017-02-07xplist: Fix OOB read when parsing node text contentGravatar Nikias Bassen1-1/+1
2017-02-07xplist: Catch some more error conditionsGravatar Nikias Bassen1-34/+37
2017-02-06xplist: Prevent memory leaks when parsing failsGravatar Nikias Bassen1-37/+20
2017-01-03xplist: Refine XML parsing error messagesGravatar Nikias Bassen1-15/+18
2017-01-02xplist: Error out when invalid tags inside text nodes are encounteredGravatar Nikias Bassen1-2/+12