1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-26 00:37:43 +03:00

avoid a warning on 64bits introduced earlier make more checking on the

* parser.c: avoid a warning on 64bits introduced earlier
* parserInternals.c: make more checking on the UTF-8 input
Daniel

svn path=/trunk/; revision=3676
This commit is contained in:
Daniel Veillard
2008-01-11 08:00:57 +00:00
parent c5b43cc03a
commit b3edafd72d
3 changed files with 20 additions and 3 deletions

View File

@@ -1,3 +1,8 @@
Fri Jan 11 08:58:49 CET 2008 Daniel Veillard <daniel@veillard.com>
* parser.c: avoid a warning on 64bits introduced earlier
* parserInternals.c: make more checking on the UTF-8 input
Fri Jan 11 15:37:05 CST 2008 Daniel Veillard <daniel@veillard.com> Fri Jan 11 15:37:05 CST 2008 Daniel Veillard <daniel@veillard.com>
* HTMLparser.c: avoid stopping parsing when encountering * HTMLparser.c: avoid stopping parsing when encountering

View File

@@ -994,7 +994,7 @@ xmlCleanSpecialAttrCallback(void *payload, void *data,
const xmlChar *unused ATTRIBUTE_UNUSED) { const xmlChar *unused ATTRIBUTE_UNUSED) {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) data; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) data;
if (((int) payload) == XML_ATTRIBUTE_CDATA) { if (((long) payload) == XML_ATTRIBUTE_CDATA) {
xmlHashRemoveEntry2(ctxt->attsSpecial, fullname, fullattr, NULL); xmlHashRemoveEntry2(ctxt->attsSpecial, fullname, fullattr, NULL);
} }
} }

View File

@@ -638,14 +638,13 @@ xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
c = *cur; c = *cur;
if (c & 0x80) { if (c & 0x80) {
if (c == 0xC0) if (((c & 0x40) == 0) || (c == 0xC0))
goto encoding_error; goto encoding_error;
if (cur[1] == 0) if (cur[1] == 0)
xmlParserInputGrow(ctxt->input, INPUT_CHUNK); xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
if ((cur[1] & 0xc0) != 0x80) if ((cur[1] & 0xc0) != 0x80)
goto encoding_error; goto encoding_error;
if ((c & 0xe0) == 0xe0) { if ((c & 0xe0) == 0xe0) {
if (cur[2] == 0) if (cur[2] == 0)
xmlParserInputGrow(ctxt->input, INPUT_CHUNK); xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
if ((cur[2] & 0xc0) != 0x80) if ((cur[2] & 0xc0) != 0x80)
@@ -662,18 +661,24 @@ xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
val |= (cur[1] & 0x3f) << 12; val |= (cur[1] & 0x3f) << 12;
val |= (cur[2] & 0x3f) << 6; val |= (cur[2] & 0x3f) << 6;
val |= cur[3] & 0x3f; val |= cur[3] & 0x3f;
if (val < 0x10000)
goto encoding_error;
} else { } else {
/* 3-byte code */ /* 3-byte code */
*len = 3; *len = 3;
val = (cur[0] & 0xf) << 12; val = (cur[0] & 0xf) << 12;
val |= (cur[1] & 0x3f) << 6; val |= (cur[1] & 0x3f) << 6;
val |= cur[2] & 0x3f; val |= cur[2] & 0x3f;
if (val < 0x800)
goto encoding_error;
} }
} else { } else {
/* 2-byte code */ /* 2-byte code */
*len = 2; *len = 2;
val = (cur[0] & 0x1f) << 6; val = (cur[0] & 0x1f) << 6;
val |= cur[1] & 0x3f; val |= cur[1] & 0x3f;
if (val < 0x80)
goto encoding_error;
} }
if (!IS_CHAR(val)) { if (!IS_CHAR(val)) {
xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR, xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
@@ -683,6 +688,13 @@ xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
} else { } else {
/* 1-byte code */ /* 1-byte code */
*len = 1; *len = 1;
if (*ctxt->input->cur == 0)
xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
if ((*ctxt->input->cur == 0) &&
(ctxt->input->end > ctxt->input->cur)) {
xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
"Char 0x0 out of allowed range\n", 0);
}
if (*ctxt->input->cur == 0xD) { if (*ctxt->input->cur == 0xD) {
if (ctxt->input->cur[1] == 0xA) { if (ctxt->input->cur[1] == 0xA) {
ctxt->nbChars++; ctxt->nbChars++;