Browse Source

readonly protection for copied array

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1385 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.1
Xuefer 8 years ago
parent
commit
e715a91978
  1. 12
      processor/processor.m4
  2. 1
      processor/struct.m4
  3. 9
      util/xc_stack.c
  4. 3
      xcache/xc_allocator_bestfit.c
  5. 6
      xcache/xc_utils.c

12
processor/processor.m4

@ -668,9 +668,11 @@ DEF_STRUCT_P_FUNC(`zend_op', , `dnl {{{
# ifdef ZEND_FAST_CALL
case ZEND_FAST_CALL:
# endif
assert(Z_OP(SRC(`op1')).jmp_addr >= processor->active_op_array_src->opcodes && Z_OP(SRC(`op1')).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
assert(Z_OP(SRC(`op1')).jmp_addr >= processor->active_op_array_src->opcodes);
assert(Z_OP(SRC(`op1')).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
Z_OP(DST(`op1')).jmp_addr = processor->active_op_array_dst->opcodes + (Z_OP(SRC(`op1')).jmp_addr - processor->active_op_array_src->opcodes);
assert(Z_OP(DST(`op1')).jmp_addr >= processor->active_op_array_dst->opcodes && Z_OP(DST(`op1')).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
assert(Z_OP(DST(`op1')).jmp_addr >= processor->active_op_array_dst->opcodes);
assert(Z_OP(DST(`op1')).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
break;
case ZEND_JMPZ:
@ -683,9 +685,11 @@ DEF_STRUCT_P_FUNC(`zend_op', , `dnl {{{
# ifdef ZEND_JMP_SET_VAR
case ZEND_JMP_SET_VAR:
# endif
assert(Z_OP(SRC(`op2')).jmp_addr >= processor->active_op_array_src->opcodes && Z_OP(SRC(`op2')).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
assert(Z_OP(SRC(`op2')).jmp_addr >= processor->active_op_array_src->opcodes);
assert(Z_OP(SRC(`op2')).jmp_addr - processor->active_op_array_src->opcodes < processor->active_op_array_src->last);
Z_OP(DST(`op2')).jmp_addr = processor->active_op_array_dst->opcodes + (Z_OP(SRC(`op2')).jmp_addr - processor->active_op_array_src->opcodes);
assert(Z_OP(DST(`op2')).jmp_addr >= processor->active_op_array_dst->opcodes && Z_OP(DST(`op2')).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
assert(Z_OP(DST(`op2')).jmp_addr >= processor->active_op_array_dst->opcodes);
assert(Z_OP(DST(`op2')).jmp_addr - processor->active_op_array_dst->opcodes < processor->active_op_array_dst->last);
break;
default:

1
processor/struct.m4

@ -233,6 +233,7 @@ define(`STRUCT_ARRAY', `
ifelse(`$2', `', `IFCOPY(`DST(`$4[LOOPCOUNTER]') = NULL;')')
')dnl IFDASM
DONE(`$4')
FIXPOINTER(`$3', `$4')
popdef(`FUNC_NAME')
popdef(`LOOPCOUNTER')
}

9
util/xc_stack.c

@ -27,19 +27,22 @@ void xc_stack_push(S stack, void *item)
void* xc_stack_pop(S stack)
{
assert(stack != NULL && stack->size > 0);
assert(stack != NULL);
assert(stack->size > 0);
return stack->data[--stack->cnt];
}
void* xc_stack_top(S stack)
{
assert(stack != NULL && stack->cnt > 0);
assert(stack != NULL);
assert(stack->cnt > 0);
return stack->data[stack->cnt-1];
}
void* xc_stack_get(S stack, int n)
{
assert(stack != NULL && stack->cnt > 0);
assert(stack != NULL);
assert(stack->cnt > 0);
return stack->data[n];
}

3
xcache/xc_allocator_bestfit.c

@ -192,7 +192,8 @@ static XC_ALLOCATOR_FREE(xc_allocator_bestfit_free) /* {{{ return block size fre
cur = (xc_allocator_bestfit_block_t *) (CHAR_PTR(p) - BLOCK_HEADER_SIZE());
TRACE("freeing: %p, size=%lu", p, cur->size);
xc_block_check(cur);
assert((char*)allocator < (char*)cur && (char*)cur < (char*)allocator + allocator->size);
assert((char*)allocator < (char*)cur);
assert((char*)cur < (char*)allocator + allocator->size);
/* find free block right before the p */
b = allocator->headblock;

6
xcache/xc_utils.c

@ -156,7 +156,8 @@ int xc_undo_pass_two(zend_op_array *op_array TSRMLS_DC) /* {{{ */
# ifdef ZEND_FAST_CALL
case ZEND_FAST_CALL:
# endif
assert(Z_OP(opline->op1).jmp_addr >= op_array->opcodes && (zend_uint) (Z_OP(opline->op1).jmp_addr - op_array->opcodes) < op_array->last);
assert(Z_OP(opline->op1).jmp_addr >= op_array->opcodes);
assert((zend_uint) (Z_OP(opline->op1).jmp_addr - op_array->opcodes) < op_array->last);
Z_OP(opline->op1).opline_num = Z_OP(opline->op1).jmp_addr - op_array->opcodes;
break;
case ZEND_JMPZ:
@ -169,7 +170,8 @@ int xc_undo_pass_two(zend_op_array *op_array TSRMLS_DC) /* {{{ */
# ifdef ZEND_JMP_SET_VAR
case ZEND_JMP_SET_VAR:
# endif
assert(Z_OP(opline->op2).jmp_addr >= op_array->opcodes && (zend_uint) (Z_OP(opline->op2).jmp_addr - op_array->opcodes) < op_array->last);
assert(Z_OP(opline->op2).jmp_addr >= op_array->opcodes);
assert((zend_uint) (Z_OP(opline->op2).jmp_addr - op_array->opcodes) < op_array->last);
Z_OP(opline->op2).opline_num = Z_OP(opline->op2).jmp_addr - op_array->opcodes;
break;
}

Loading…
Cancel
Save