1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-11-02 13:33:20 +03:00

Fix xsl:number generating invalid UTF-8

xsl:number with an empty grouping separator would generate 0xFF bytes.

Found by OSS-Fuzz.
This commit is contained in:
Nick Wellnhofer
2021-03-02 12:45:43 +01:00
parent 242f196849
commit d25b8c6c8d
5 changed files with 51 additions and 0 deletions

View File

@@ -1494,6 +1494,8 @@ xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur) {
comp->numdata.groupingCharacterLen = xmlStrlen(prop); comp->numdata.groupingCharacterLen = xmlStrlen(prop);
comp->numdata.groupingCharacter = comp->numdata.groupingCharacter =
xsltGetUTF8Char(prop, &(comp->numdata.groupingCharacterLen)); xsltGetUTF8Char(prop, &(comp->numdata.groupingCharacterLen));
if (comp->numdata.groupingCharacter < 0)
comp->numdata.groupingCharacter = 0;
} }
prop = xsltGetCNsProp(style, cur, (const xmlChar *)"grouping-size", XSLT_NAMESPACE); prop = xsltGetCNsProp(style, cur, (const xmlChar *)"grouping-size", XSLT_NAMESPACE);

View File

@@ -74,6 +74,7 @@ EXTRA_DIST = \
test-7.7-3.out test-7.7-3.xml test-7.7-3.xsl \ test-7.7-3.out test-7.7-3.xml test-7.7-3.xsl \
test-7.7-4.out test-7.7-4.xml test-7.7-4.xsl \ test-7.7-4.out test-7.7-4.xml test-7.7-4.xsl \
test-7.7-5.out test-7.7-5.xml test-7.7-5.xsl \ test-7.7-5.out test-7.7-5.xml test-7.7-5.xsl \
test-7.7-6.out test-7.7-6.xml test-7.7-6.xsl \
test-8-1.out test-8-1.xml test-8-1.xsl \ test-8-1.out test-8-1.xml test-8-1.xsl \
test-9.1-1.out test-9.1-1.xml test-9.1-1.xsl \ test-9.1-1.out test-9.1-1.xml test-9.1-1.xsl \
test-9.1-2.out test-9.1-2.xml test-9.1-2.xsl \ test-9.1-2.out test-9.1-2.xml test-9.1-2.xsl \

11
tests/REC/test-7.7-6.out Normal file
View File

@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<results>
<r>1.234.567.890</r>
<r>1234567890</r>
<r>1.2.3.4.5.6.7.8.9.0</r>
<r>1234567890</r>
<r>1234567890</r>
<r>1234567890</r>
<r>1234567890</r>
<r>1234567890</r>
</results>

1
tests/REC/test-7.7-6.xml Normal file
View File

@@ -0,0 +1 @@
<doc/>

36
tests/REC/test-7.7-6.xsl Normal file
View File

@@ -0,0 +1,36 @@
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:template match="/">
<results>
<r>
<xsl:number value="1234567890" grouping-separator="." grouping-size="3"/>
</r>
<r>
<xsl:number value="1234567890" grouping-separator="" grouping-size="3"/>
</r>
<r>
<xsl:number value="1234567890" grouping-separator="." grouping-size="1"/>
</r>
<r>
<xsl:number value="1234567890" grouping-separator="." grouping-size="0"/>
</r>
<r>
<xsl:number value="1234567890" grouping-separator="." grouping-size="-1"/>
</r>
<r>
<xsl:number value="1234567890" grouping-separator="." grouping-size="99"/>
</r>
<r>
<xsl:number value="1234567890" grouping-separator="." grouping-size="abc"/>
</r>
<r>
<xsl:number value="1234567890" grouping-separator="" grouping-size="3"/>
</r>
</results>
</xsl:template>
</xsl:stylesheet>