xmllite: Return WC_E_SYNTAX if there is unexpected data in the end of the stream.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
6797ee0abf
commit
68aeee4d79
|
@ -2610,14 +2610,17 @@ static HRESULT reader_parse_nextnode(xmlreader *reader)
|
|||
return reader_parse_content(reader);
|
||||
case XmlReadInState_MiscEnd:
|
||||
hr = reader_parse_misc(reader);
|
||||
if (FAILED(hr)) return hr;
|
||||
if (hr != S_FALSE) return hr;
|
||||
|
||||
if (hr == S_FALSE)
|
||||
if (*reader_get_ptr(reader))
|
||||
{
|
||||
reader->instate = XmlReadInState_Eof;
|
||||
reader->state = XmlReadState_EndOfFile;
|
||||
reader->nodetype = XmlNodeType_None;
|
||||
WARN("found garbage in the end of XML\n");
|
||||
return WC_E_SYNTAX;
|
||||
}
|
||||
|
||||
reader->instate = XmlReadInState_Eof;
|
||||
reader->state = XmlReadState_EndOfFile;
|
||||
reader->nodetype = XmlNodeType_None;
|
||||
return hr;
|
||||
case XmlReadInState_Eof:
|
||||
return S_FALSE;
|
||||
|
|
|
@ -2354,6 +2354,7 @@ static void test_eof_state(IXmlReader *reader, BOOL eof)
|
|||
static void test_endoffile(void)
|
||||
{
|
||||
static const char *xml = "<a/>";
|
||||
static const char *xml_garbageend = "<a/>text";
|
||||
IXmlReader *reader;
|
||||
XmlNodeType type;
|
||||
IStream *stream;
|
||||
|
@ -2393,6 +2394,33 @@ static void test_endoffile(void)
|
|||
IStream_Release(stream);
|
||||
|
||||
IXmlReader_Release(reader);
|
||||
|
||||
hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL);
|
||||
ok(hr == S_OK, "S_OK, got %08x\n", hr);
|
||||
|
||||
stream = create_stream_on_data(xml_garbageend, strlen(xml_garbageend));
|
||||
hr = IXmlReader_SetInput(reader, (IUnknown *)stream);
|
||||
ok(hr == S_OK, "got %08x\n", hr);
|
||||
IStream_Release(stream);
|
||||
|
||||
type = XmlNodeType_None;
|
||||
hr = IXmlReader_Read(reader, &type);
|
||||
ok(hr == S_OK, "got %#x\n", hr);
|
||||
ok(type == XmlNodeType_Element, "Unexpected type %d\n", type);
|
||||
|
||||
test_eof_state(reader, FALSE);
|
||||
|
||||
type = XmlNodeType_Element;
|
||||
hr = IXmlReader_Read(reader, &type);
|
||||
ok(hr == WC_E_SYNTAX, "got %#x\n", hr);
|
||||
ok(type == XmlNodeType_None, "Unexpected type %d\n", type);
|
||||
|
||||
test_eof_state(reader, FALSE);
|
||||
|
||||
hr = IXmlReader_SetInput(reader, NULL);
|
||||
ok(hr == S_OK, "got %08x\n", hr);
|
||||
|
||||
IXmlReader_Release(reader);
|
||||
}
|
||||
|
||||
static void test_max_element_depth(void)
|
||||
|
|
Loading…
Reference in New Issue