summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzherczeg <zherczeg@2f5784b3-3f2a-0410-8824-cb99058d5e15>2012-10-20 20:52:52 +0000
committerzherczeg <zherczeg@2f5784b3-3f2a-0410-8824-cb99058d5e15>2012-10-20 20:52:52 +0000
commitcb2d2c4744966facc4c43cceee213eb33020884d (patch)
treefb3b659b607db50d6ce87d6934e136f07df30b0f
parentc582ff7938b58916516318096d56225ea0bf71c8 (diff)
downloadpcre-cb2d2c4744966facc4c43cceee213eb33020884d.tar.gz
Refactor the solution of the unsigned overflow.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1148 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--pcre_compile.c22
-rw-r--r--pcre_study.c17
2 files changed, 18 insertions, 21 deletions
diff --git a/pcre_compile.c b/pcre_compile.c
index ac38484..0958039 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -1914,25 +1914,19 @@ for (;;)
/* Check a class for variable quantification */
-#if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- case OP_XCLASS:
-#endif
case OP_CLASS:
case OP_NCLASS:
-
- switch (op)
- {
#if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- case OP_XCLASS:
+ case OP_XCLASS:
+ /* The original code caused an unsigned overflow in 64 bit systems,
+ so now we use a conditional statement. */
+ if (op == OP_XCLASS)
cc += GET(cc, 1);
- break;
-#endif
-
- case OP_CLASS:
- case OP_NCLASS:
+ else
cc += PRIV(OP_lengths)[OP_CLASS];
- break;
- }
+#else
+ cc += PRIV(OP_lengths)[OP_CLASS];
+#endif
switch (*cc)
{
diff --git a/pcre_study.c b/pcre_study.c
index 9045185..2205dd7 100644
--- a/pcre_study.c
+++ b/pcre_study.c
@@ -323,16 +323,19 @@ for (;;)
/* Check a class for variable quantification */
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- case OP_XCLASS:
- cc += GET(cc, 1);
- cc -= PRIV(OP_lengths)[OP_CLASS];
- /* Fall through */
-#endif
-
case OP_CLASS:
case OP_NCLASS:
+#if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
+ case OP_XCLASS:
+ /* The original code caused an unsigned overflow in 64 bit systems,
+ so now we use a conditional statement. */
+ if (op == OP_XCLASS)
+ cc += GET(cc, 1);
+ else
+ cc += PRIV(OP_lengths)[OP_CLASS];
+#else
cc += PRIV(OP_lengths)[OP_CLASS];
+#endif
switch (*cc)
{