mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
detect combinatory explosion and return with a runtime error in those
* xmlregexp.c: detect combinatory explosion and return with a runtime error in those case, c.f. #316338 though maybe we should not see such an explosion with that specific regexp, more checking needs to be done. Daniel
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
Thu Sep 15 15:08:21 CEST 2005 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* xmlregexp.c: detect combinatory explosion and return with
|
||||||
|
a runtime error in those case, c.f. #316338 though maybe we
|
||||||
|
should not see such an explosion with that specific regexp,
|
||||||
|
more checking needs to be done.
|
||||||
|
|
||||||
Wed Sep 14 19:52:18 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
|
Wed Sep 14 19:52:18 CEST 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
|
||||||
|
|
||||||
* include/libxml/schemasInternals.h: Added some comments for the
|
* include/libxml/schemasInternals.h: Added some comments for the
|
||||||
|
16
xmlregexp.c
16
xmlregexp.c
@ -42,6 +42,8 @@
|
|||||||
/* #define DEBUG_PUSH */
|
/* #define DEBUG_PUSH */
|
||||||
/* #define DEBUG_COMPACTION */
|
/* #define DEBUG_COMPACTION */
|
||||||
|
|
||||||
|
#define MAX_PUSH 100000
|
||||||
|
|
||||||
#define ERROR(str) \
|
#define ERROR(str) \
|
||||||
ctxt->error = XML_REGEXP_COMPILE_ERROR; \
|
ctxt->error = XML_REGEXP_COMPILE_ERROR; \
|
||||||
xmlRegexpErrCompile(ctxt, str);
|
xmlRegexpErrCompile(ctxt, str);
|
||||||
@ -326,6 +328,7 @@ struct _xmlRegExecCtxt {
|
|||||||
xmlRegStatePtr errState; /* the error state */
|
xmlRegStatePtr errState; /* the error state */
|
||||||
xmlChar *errString; /* the string raising the error */
|
xmlChar *errString; /* the string raising the error */
|
||||||
int *errCounts; /* counters at the error state */
|
int *errCounts; /* counters at the error state */
|
||||||
|
int nbPush;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define REGEXP_ALL_COUNTER 0x123456
|
#define REGEXP_ALL_COUNTER 0x123456
|
||||||
@ -2336,6 +2339,12 @@ xmlFARegExecSave(xmlRegExecCtxtPtr exec) {
|
|||||||
xmlFARegDebugExec(exec);
|
xmlFARegDebugExec(exec);
|
||||||
exec->transno--;
|
exec->transno--;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef MAX_PUSH
|
||||||
|
if (exec->nbPush > MAX_PUSH) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
exec->nbPush++;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (exec->maxRollbacks == 0) {
|
if (exec->maxRollbacks == 0) {
|
||||||
exec->maxRollbacks = 4;
|
exec->maxRollbacks = 4;
|
||||||
@ -2426,6 +2435,7 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
|
|||||||
|
|
||||||
exec->inputString = content;
|
exec->inputString = content;
|
||||||
exec->index = 0;
|
exec->index = 0;
|
||||||
|
exec->nbPush = 0;
|
||||||
exec->determinist = 1;
|
exec->determinist = 1;
|
||||||
exec->maxRollbacks = 0;
|
exec->maxRollbacks = 0;
|
||||||
exec->nbRollbacks = 0;
|
exec->nbRollbacks = 0;
|
||||||
@ -2632,8 +2642,11 @@ progress:
|
|||||||
xmlFree(exec->counts);
|
xmlFree(exec->counts);
|
||||||
if (exec->status == 0)
|
if (exec->status == 0)
|
||||||
return(1);
|
return(1);
|
||||||
if (exec->status == -1)
|
if (exec->status == -1) {
|
||||||
|
if (exec->nbPush > MAX_PUSH)
|
||||||
|
return(-1);
|
||||||
return(0);
|
return(0);
|
||||||
|
}
|
||||||
return(exec->status);
|
return(exec->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2708,6 +2721,7 @@ xmlRegNewExecCtxt(xmlRegexpPtr comp, xmlRegExecCallbacks callback, void *data) {
|
|||||||
exec->inputStack = NULL;
|
exec->inputStack = NULL;
|
||||||
exec->errStateNo = -1;
|
exec->errStateNo = -1;
|
||||||
exec->errString = NULL;
|
exec->errString = NULL;
|
||||||
|
exec->nbPush = 0;
|
||||||
return(exec);
|
return(exec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user