diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2019-03-08 12:15:17 +0100 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2019-03-08 14:29:59 +0100 |
commit | 30a6533e010c740a7281a0c8960b4db9212f5f75 (patch) | |
tree | 420c1bdffc571fbe1675978250b07285265afc5f /test/XPath/expr | |
parent | 09797c139e5b0168c87f41b2cea1078d7244638d (diff) | |
download | libxml2-30a6533e010c740a7281a0c8960b4db9212f5f75.tar.gz |
Fix float casts in xmlXPathSubstringFunction
Rewrite conversion of double to int in xmlXPathSubstringFunction, adding
range checks to avoid undefined behavior. Make sure to add start and
length as floating-point numbers before converting to int. Fix a bug
when rounding negative start indices.
Remove unneeded calls to xmlXPathIs{Inf,NaN} and rely on IEEE math
instead. Avoid computing the string length. xmlUTF8Strsub works as
expected if the length of the requested substring exceeds the input.
Found with libFuzzer and UBSan.
Diffstat (limited to 'test/XPath/expr')
-rw-r--r-- | test/XPath/expr/strings | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/test/XPath/expr/strings b/test/XPath/expr/strings index ba02c794..c741ee25 100644 --- a/test/XPath/expr/strings +++ b/test/XPath/expr/strings @@ -32,5 +32,7 @@ substring("12345",3,-1 div 0) substring("12345",-42, 1 div 0) substring("12345",-1 div 0, 1 div 0) substring("12345",-1 div 0,5) +substring("12345",-0.7,4) +substring("12345",-5000000000,5000000004) string-length("") string-length("titi") |