|
|
1e2217 |
From be692806851f4883b87fc814adc80ab1bb46455e Mon Sep 17 00:00:00 2001
|
|
|
1e2217 |
From: zherczeg <zherczeg@2f5784b3-3f2a-0410-8824-cb99058d5e15>
|
|
|
1e2217 |
Date: Sat, 26 Jan 2013 17:51:43 +0000
|
|
|
1e2217 |
Subject: [PATCH] Fix two buffer over read issues in 16 and 32 bit modes.
|
|
|
1e2217 |
Affects JIT only.
|
|
|
1e2217 |
|
|
|
1e2217 |
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1242 2f5784b3-3f2a-0410-8824-cb99058d5e15
|
|
|
1e2217 |
|
|
|
1e2217 |
Petr Pisar: Ported to 8.32.
|
|
|
1e2217 |
|
|
|
1e2217 |
diff --git a/pcre_jit_compile.c b/pcre_jit_compile.c
|
|
|
1e2217 |
index 3b83340..7dfe558 100644
|
|
|
1e2217 |
--- a/pcre_jit_compile.c
|
|
|
1e2217 |
+++ b/pcre_jit_compile.c
|
|
|
1e2217 |
@@ -2696,10 +2696,10 @@ if (firstline)
|
|
|
1e2217 |
{
|
|
|
1e2217 |
SLJIT_ASSERT(common->first_line_end != 0);
|
|
|
1e2217 |
OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);
|
|
|
1e2217 |
- OP2(SLJIT_SUB, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end, SLJIT_IMM, (location >> 1) - 1);
|
|
|
1e2217 |
+ OP2(SLJIT_SUB, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end, SLJIT_IMM, IN_UCHARS((location >> 1) - 1));
|
|
|
1e2217 |
}
|
|
|
1e2217 |
else
|
|
|
1e2217 |
- OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, (location >> 1) - 1);
|
|
|
1e2217 |
+ OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS((location >> 1) - 1));
|
|
|
1e2217 |
|
|
|
1e2217 |
start = LABEL();
|
|
|
1e2217 |
quit = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
|
|
|
1e2217 |
@@ -2728,7 +2728,7 @@ JUMPHERE(quit);
|
|
|
1e2217 |
if (firstline)
|
|
|
1e2217 |
OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
|
|
|
1e2217 |
else
|
|
|
1e2217 |
- OP2(SLJIT_ADD, STR_END, 0, STR_END, 0, SLJIT_IMM, (location >> 1) - 1);
|
|
|
1e2217 |
+ OP2(SLJIT_ADD, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS((location >> 1) - 1));
|
|
|
1e2217 |
return TRUE;
|
|
|
1e2217 |
}
|
|
|
1e2217 |
|
|
|
1e2217 |
@@ -3577,7 +3577,7 @@ do
|
|
|
1e2217 |
#endif
|
|
|
1e2217 |
|
|
|
1e2217 |
context->length -= IN_UCHARS(1);
|
|
|
1e2217 |
-#if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
|
|
|
1e2217 |
+#if (defined SLJIT_UNALIGNED && SLJIT_UNALIGNED) && (defined COMPILE_PCRE8 || defined COMPILE_PCRE16)
|
|
|
1e2217 |
|
|
|
1e2217 |
/* Unaligned read is supported. */
|
|
|
1e2217 |
if (othercasebit != 0 && othercasechar == cc)
|
|
|
1e2217 |
@@ -3594,27 +3594,18 @@ do
|
|
|
1e2217 |
|
|
|
1e2217 |
#if defined COMPILE_PCRE8
|
|
|
1e2217 |
if (context->ucharptr >= 4 || context->length == 0 || (context->ucharptr == 2 && context->length == 1))
|
|
|
1e2217 |
-#elif defined COMPILE_PCRE16
|
|
|
1e2217 |
+#else
|
|
|
1e2217 |
if (context->ucharptr >= 2 || context->length == 0)
|
|
|
1e2217 |
-#elif defined COMPILE_PCRE32
|
|
|
1e2217 |
- if (1 /* context->ucharptr >= 1 || context->length == 0 */)
|
|
|
1e2217 |
#endif
|
|
|
1e2217 |
{
|
|
|
1e2217 |
-#if defined COMPILE_PCRE8 || defined COMPILE_PCRE16
|
|
|
1e2217 |
if (context->length >= 4)
|
|
|
1e2217 |
OP1(SLJIT_MOV_SI, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
|
|
|
1e2217 |
-#if defined COMPILE_PCRE8
|
|
|
1e2217 |
else if (context->length >= 2)
|
|
|
1e2217 |
OP1(SLJIT_MOV_UH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
|
|
|
1e2217 |
+#if defined COMPILE_PCRE8
|
|
|
1e2217 |
else if (context->length >= 1)
|
|
|
1e2217 |
OP1(SLJIT_MOV_UB, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
|
|
|
1e2217 |
-#elif defined COMPILE_PCRE16
|
|
|
1e2217 |
- else if (context->length >= 2)
|
|
|
1e2217 |
- OP1(SLJIT_MOV_UH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
|
|
|
1e2217 |
-#endif /* COMPILE_PCRE[8|16] */
|
|
|
1e2217 |
-#elif defined COMPILE_PCRE32
|
|
|
1e2217 |
- OP1(MOV_UCHAR, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
|
|
|
1e2217 |
-#endif /* COMPILE_PCRE[8|16|32] */
|
|
|
1e2217 |
+#endif /* COMPILE_PCRE8 */
|
|
|
1e2217 |
context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;
|
|
|
1e2217 |
|
|
|
1e2217 |
switch(context->ucharptr)
|
|
|
1e2217 |
@@ -3625,7 +3616,6 @@ do
|
|
|
1e2217 |
add_jump(compiler, backtracks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asint | context->oc.asint));
|
|
|
1e2217 |
break;
|
|
|
1e2217 |
|
|
|
1e2217 |
-#if defined COMPILE_PCRE8 || defined COMPILE_PCRE16
|
|
|
1e2217 |
case 2 / sizeof(pcre_uchar):
|
|
|
1e2217 |
if (context->oc.asushort != 0)
|
|
|
1e2217 |
OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asushort);
|
|
|
1e2217 |
@@ -3640,8 +3630,6 @@ do
|
|
|
1e2217 |
break;
|
|
|
1e2217 |
#endif
|
|
|
1e2217 |
|
|
|
1e2217 |
-#endif /* COMPILE_PCRE[8|16] */
|
|
|
1e2217 |
-
|
|
|
1e2217 |
default:
|
|
|
1e2217 |
SLJIT_ASSERT_STOP();
|
|
|
1e2217 |
break;
|
|
|
1e2217 |
@@ -3651,8 +3639,8 @@ do
|
|
|
1e2217 |
|
|
|
1e2217 |
#else
|
|
|
1e2217 |
|
|
|
1e2217 |
- /* Unaligned read is unsupported. */
|
|
|
1e2217 |
- if (context->length > 0)
|
|
|
1e2217 |
+ /* Unaligned read is unsupported or in 32 bit mode. */
|
|
|
1e2217 |
+ if (context->length >= 1)
|
|
|
1e2217 |
OP1(MOV_UCHAR, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
|
|
|
1e2217 |
|
|
|
1e2217 |
context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;
|
|
|
1e2217 |
--
|
|
|
1e2217 |
1.8.1
|
|
|
1e2217 |
|