aboutsummaryrefslogtreecommitdiff
path: root/xpath.c
AgeCommit message (Collapse)Author
2023-09-21doc: Make apibuild.py happyNick Wellnhofer
2023-09-21include: Remove more unnecessary includesNick Wellnhofer
2023-09-20globals: Stop including globals.hNick Wellnhofer
2023-09-19debug: Remove debugging codeNick Wellnhofer
This is barely useful these days and only clutters the code base.
2023-05-30xpath: Ignore entity ref nodes when computing node hashNick Wellnhofer
XPath queries only work reliably if entities are substituted. Nevertheless, it's possible to query a document with entity reference nodes. xmllint even deletes entities when the `--dropdtd` option is passed, resulting in dangling pointers, so it's best to skip entity reference nodes to avoid a use-after-free. Fixes #550.
2023-05-08xpath: Fix build without LIBXML_XPATH_ENABLEDNick Wellnhofer
Move static function declaration into XPATH block. Also move comparison functions. Fixes #537.
2023-03-18malloc-fail: Check for malloc failures when creating XPath stringsNick Wellnhofer
Prevent null derefs. Found by OSS-Fuzz, see #344.
2023-03-13malloc-fail: Stop using XPath stack framesNick Wellnhofer
There's too much code which assumes that if ctxt->value is non-null, a value can be successfully popped off the stack. This assumption can break with stack frames when malloc fails. Instead of trying to fix all call sites, remove the stack frame logic. It only offered very little protection against misbehaving extension functions. We already check the stack size after a function call which should be enough. Found by OSS-Fuzz.
2023-03-09malloc-fail: Fix memory leak in xmlXPathRegisterNsNick Wellnhofer
Found by OSS-Fuzz.
2023-02-28malloc-fail: Fix memory leak in xmlXPathNameFunctionNick Wellnhofer
Found with libFuzzer, see #344.
2023-02-27xpath: Fix harmless integer overflow in xmlXPathTranslateFunctionNick Wellnhofer
2023-02-27Revert "xpath: Fix popping of values in xmlXPathPopNodeset"Nick Wellnhofer
This reverts commit 47b0e0a620d1e0e657b858986e3ebde80d4645b4.
2023-02-27malloc-fail: Fix memory leak in xmlXPathDistinctSortedNick Wellnhofer
Found with libFuzzer, see #344.
2023-02-27malloc-fail: Fix memory leak in xmlXPathCacheNewNodeSetNick Wellnhofer
Found with libFuzzer, see #344.
2023-02-27malloc-fail: Fix null deref after xmlPointerListAddSizeNick Wellnhofer
Found with libFuzzer, see #344.
2023-02-27malloc-fail: Fix null deref in xmlXPathCompiledEvalInternalNick Wellnhofer
Found with libFuzzer, see #344.
2023-02-26malloc-fail: Fix use-after-free related to xmlXPathNodeSetFilterNick Wellnhofer
Found with libFuzzer, see #344.
2023-02-26malloc-fail: Fix memory leak in xmlXPathEqualNodeSetFloatNick Wellnhofer
Found with libFuzzer, see #344.
2023-02-26Revert "malloc-fail: Avoid use-after-free after unsuccessful valuePush"Nick Wellnhofer
This reverts commit 6a12be77c6a94c374ab7476087edcee2ba41d9b4. There's too much code reading ctxt->value directly and making the wrong assumptions.
2023-02-23xpath: Fix popping of values in xmlXPathPopNodesetNick Wellnhofer
After 6a12be77, valuePop can fail even if ctxt->value is non-NULL. If it turns out that too much code relies on this assumption, a better fix is needed.
2023-02-17malloc-fail: Fix memory leak after calling xmlXPathNodeSetMergeNick Wellnhofer
Destroy the first argument in xmlXPathNodeSetMerge if the function fails. This is somewhat dangerous but matches the expectations of users. Found with libFuzzer, see #344.
2023-02-17malloc-fail: Fix memory leak after calling xmlXPathWrapStringNick Wellnhofer
Destroy the string in xmlXPathWrapString if the function fails. This is somewhat dangerous but matches the expectations of users. Found with libFuzzer, see #344.
2023-02-17malloc-fail: Fix memory leak in xmlXPathEqualValuesCommonNick Wellnhofer
Found with libFuzzer, see #344.
2023-02-17malloc-fail: Fix memory leak in xmlXPathCompareValuesNick Wellnhofer
Found with libFuzzer, see #344.
2023-02-17malloc-fail: Fix memory leak in xmlXPathTryStreamCompileNick Wellnhofer
Found with libFuzzer, see #344.
2023-02-17malloc-fail: Fix memory leak after calling valuePushNick Wellnhofer
Destroy the object in valuePush if the function fails. This is somewhat dangerous but matches the expectations of users. Found with libFuzzer, see #344.
2023-02-17malloc-fail: Fix memory leak after calling xmlXPathWrapNodeSetNick Wellnhofer
Destroy the node set in xmlXPathWrapNodeSet if the function fails. This is somewhat dangerous but matches the expectations of users. Found with libFuzzer, see #344.
2023-02-03xpath: Only report the first errorNick Wellnhofer
Don't overwrite the original error code. Besides, subsequent error reports are somewhat unreliable and not really useful.
2023-02-03malloc-fail: Avoid use-after-free after unsuccessful valuePushNick Wellnhofer
In xpath.c there's a lot of code like: valuePush(ctxt, xmlCacheNewX()); ... valuePop(ctxt); If xmlCacheNewX fails, no value will be pushed on the stack. If there's no error check in between, valuePop will pop an unrelated value which can lead to use-after-free errors. Instead of trying to fix all call sites, we simply stop popping values if an error was signaled. This requires to change the CHECK_TYPE macro which is often used to determine whether a value can be safely popped. Found with libFuzzer, see #344.
2023-02-03malloc-fail: Add error checks in xmlXPathEqualValuesCommonNick Wellnhofer
Avoid null deref. Found with libFuzzer, see #344.
2023-02-03malloc-fail: Add error check in xmlXPathEqualNodeSetFloatNick Wellnhofer
Avoid null deref. Found with libFuzzer, see #344.
2023-02-03malloc-fail: Fix error check in xmlXPathCompareValuesNick Wellnhofer
Avoid null deref. Found with libFuzzer, see #344.
2023-02-03malloc-fail: Record malloc failure in xmlXPathCompLiteralNick Wellnhofer
Avoid OOB array access. Found with libFuzzer, see #344.
2023-02-03malloc-fail: Check return value of xmlXPathNodeSetDupNsNick Wellnhofer
Avoid null deref if allocation fails. Found with libFuzzer, see #344.
2023-01-18xpath: number('-') should return NaNNick Wellnhofer
Fixes https://gitlab.gnome.org/GNOME/libxslt/-/issues/81
2022-11-27xpath: Make init function privateNick Wellnhofer
2022-10-25warnings: Remove set-but-unused variablesNick Wellnhofer
Fixes compiler warnings with clang 15.
2022-09-07xpath: Lower XPath recursion limit on WindowsNick Wellnhofer
2022-09-04Fix Windows compiler warnings in python/types.cNick Wellnhofer
2022-09-01Remove or annotate char castsNick Wellnhofer
2022-09-01Don't use sizeof(xmlChar) or sizeof(char)Nick Wellnhofer
2022-09-01Remove explicit integer castsNick Wellnhofer
Remove explicit integer casts as final operation - in assignments - when passing arguments - when returning values Remove casts - to the same type - from certain range-bound values The main motivation is that these explicit casts don't change the result of operations and only render UBSan's implicit-conversion checks useless. Removing these casts allows UBSan to detect cases where truncation or sign-changes occur unexpectedly. Document some explicit casts as truncating and add a few missing ones.
2022-08-26Remove set-but-unused variable in xmlXPathScanNameNick Wellnhofer
Fix clang warning.
2022-08-26Consolidate private header filesNick Wellnhofer
Private functions were previously declared - in header files in the root directory - in public headers guarded with IN_LIBXML - in libxml.h - redundantly in source files that used them. Consolidate all private header files in include/private.
2022-07-28Make XPath depth check work with recursive invocationsNick Wellnhofer
EXSLT functions like dyn:map or dyn:evaluate invoke xmlXPathRunEval recursively. Don't set depth to zero but keep and restore the original value to avoid stack overflows when abusing these functions.
2022-07-06Use NAN/INFINITY if available to init XPath NaN/InfSergey Kosukhin
2022-04-21Add configuration flag for XPointer locations supportNick Wellnhofer
Add a new configuration flag that controls whether the outdated support for XPointer locations (ranges and points) is enabled. --with-xptr-locs # Autotools LIBXML2_WITH_XPTR_LOCS # CMake The latest spec for what it essentially an XPath extension seems to be this working draft from 2002: https://www.w3.org/TR/xptr-xpointer/ The xpointer() scheme is listed as "being reviewed" in the XPointer registry since at least 2006. libxml2 seems to be the only modern software that tries to implement this spec, but the code has many bugs and quality issues. The flag defaults to "off" and support for this extensions has to be requested explicitly. The relevant API functions are deprecated.
2022-04-07Mark more static data as `const`David Kilzer
Similar to 8f5710379, mark more static data structures with `const` keyword. Also fix placement of `const` in encoding.c. Original patch by Sarah Wilkin.
2022-04-03Initialize XPath floating-point globalsNick Wellnhofer
Should fix #138.
2022-03-30fix: xmlXPathParserContext could be double-delete in OOM case.jinsub ahn