1
0
mirror of https://github.com/MariaDB/server.git synced 2026-10-23 18:49:29 +03:00

MDEV-40357 Server crashes in XMLSchema_group_reference::validate_prepare.

The <group> in the XML Schema can't be empty. Launch an error if that
happens.
This commit is contained in:
Alexey (Holyfoot) Botchkov
2026-07-14 15:06:12 +03:00
committed by Alexey Botchkov
parent cbf9f65771
commit f7d5457ef1
3 changed files with 49 additions and 0 deletions

View File

@@ -1862,6 +1862,7 @@ public:
bool enter_tag(MY_XML_VALIDATION_DATA *st,
const char *attr, size_t len) override;
bool leave(MY_XML_VALIDATION_DATA *st, const char *attr, size_t len) override;
};
@@ -3010,6 +3011,16 @@ bool XMLSchema_group_def::enter_tag(MY_XML_VALIDATION_DATA *st,
}
bool XMLSchema_group_def::leave(MY_XML_VALIDATION_DATA *st,
const char *attr, size_t len)
{
if (!m_compositor)
return MY_XML_ERROR; /* group with no compositor is not allowed. */
return XMLSchema_tag::leave(st, attr, len);
}
bool XMLSchema_group_reference::resolve_type(MY_XML_VALIDATION_DATA *st,
LEX_CSTRING *bad_type)
{

View File

@@ -2065,3 +2065,19 @@ SELECT XMLISVALID('<root/>',
</xs:complexType>
</xs:schema>') AS r;
ERROR HY000: Incorrect XML value: 'XML Schema parse error at line 4 pos 32: '
SELECT XMLISVALID('<root/>',
'<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:group name="g"/>
<xs:element name="root" type="t"/>
<xs:complexType name="t">
<xs:group ref="g"/>
</xs:complexType></xs:schema>') AS r;
ERROR HY000: Incorrect XML value: 'XML Schema parse error at line 2 pos 29: '
SELECT XMLISVALID('<root> <tag /> </root>',
'<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:group name="g"/>
<xs:element name="root" type="t"/>
<xs:complexType name="t">
<xs:group ref="g"/>
</xs:complexType></xs:schema>') AS r;
ERROR HY000: Incorrect XML value: 'XML Schema parse error at line 2 pos 29: '

View File

@@ -2169,3 +2169,25 @@ SELECT XMLISVALID('<root/>',
</xs:complexType>
</xs:schema>') AS r;
#
# MDEV-40357 Server crashes in XMLSchema_group_reference::validate_prepare.
#
--error ER_WRONG_VALUE
SELECT XMLISVALID('<root/>',
'<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:group name="g"/>
<xs:element name="root" type="t"/>
<xs:complexType name="t">
<xs:group ref="g"/>
</xs:complexType></xs:schema>') AS r;
--error ER_WRONG_VALUE
SELECT XMLISVALID('<root> <tag /> </root>',
'<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:group name="g"/>
<xs:element name="root" type="t"/>
<xs:complexType name="t">
<xs:group ref="g"/>
</xs:complexType></xs:schema>') AS r;