DO NOT MERGE: Add validation for eternal enities

https://bugzilla.gnome.org/show_bug.cgi?id=780691

Bug: 36556310
Change-Id: I9450743e167c3c73af5e4071f3fc85e81d061648
(cherry picked from commit bef9af3d89d241bcb518c20cba6da2a2fd9ba049)

xmlSetupParserForBuffer(xmlParserCtxtPtr ctxt, const xmlChar* buffer,
 const char* filename)
{
    xmlParserInputPtr input;

 if ((ctxt == NULL) || (buffer == NULL))
 return;

    input = xmlNewInputStream(ctxt);
 if (input == NULL) {
        xmlErrMemory(NULL, "parsing new buffer: out of memory\n");
        xmlClearParserCtxt(ctxt);
 return;
 }

    xmlClearParserCtxt(ctxt);
 if (filename != NULL)
        input->filename = (char *) xmlCanonicPath((const xmlChar *)filename);
    input->base = buffer;
    input->cur = buffer;
    input->end = &buffer[xmlStrlen(buffer)];
    inputPush(ctxt, input);
}

xmlSetupParserForBuffer(xmlParserCtxtPtr ctxt, const xmlChar* buffer,
 const char* filename)
{
    xmlParserInputPtr input;

 if ((ctxt == NULL) || (buffer == NULL))
 return;

    input = xmlNewInputStream(ctxt);
 if (input == NULL) {
        xmlErrMemory(NULL, "parsing new buffer: out of memory\n");
        xmlClearParserCtxt(ctxt);
 return;
 }

    xmlClearParserCtxt(ctxt);
 if (filename != NULL)
        input->filename = (char *) xmlCanonicPath((const xmlChar *)filename);
    input->base = buffer;
    input->cur = buffer;
    input->end = &buffer[xmlStrlen(buffer)];
    inputPush(ctxt, input);
}
