idx int64 | func_before string | Vulnerability Classification string | vul int64 | func_after string | patch string | CWE ID string | lines_before string | lines_after string |
|---|---|---|---|---|---|---|---|---|
11,900 | cvt_double(union VALUETYPE *p, const struct magic *m)
{
DO_CVT2(d, (double));
}
| DoS Exec Code | 0 | cvt_double(union VALUETYPE *p, const struct magic *m)
{
DO_CVT2(d, (double));
}
| @@ -1037,6 +1037,9 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
if (bytecnt > nbytes) {
bytecnt = nbytes;
}
+ if (offset > bytecnt) {
+ offset = bytecnt;
+ }
if (s == NULL) {
ms->search.s_len = 0;
ms->search.s = NULL; | CWE-20 | null | null |
11,901 | cvt_flip(int type, int flip)
{
if (flip == 0)
return type;
switch (type) {
case FILE_BESHORT:
return FILE_LESHORT;
case FILE_BELONG:
return FILE_LELONG;
case FILE_BEDATE:
return FILE_LEDATE;
case FILE_BELDATE:
return FILE_LELDATE;
case FILE_BEQUAD:
return FILE_LEQUAD;
case FILE_BEQDATE:
return FILE_LEQDATE;
case FILE_BEQLDATE:
return FILE_LEQLDATE;
case FILE_BEQWDATE:
return FILE_LEQWDATE;
case FILE_LESHORT:
return FILE_BESHORT;
case FILE_LELONG:
return FILE_BELONG;
case FILE_LEDATE:
return FILE_BEDATE;
case FILE_LELDATE:
return FILE_BELDATE;
case FILE_LEQUAD:
return FILE_BEQUAD;
case FILE_LEQDATE:
return FILE_BEQDATE;
case FILE_LEQLDATE:
return FILE_BEQLDATE;
case FILE_LEQWDATE:
return FILE_BEQWDATE;
case FILE_BEFLOAT:
return FILE_LEFLOAT;
case FILE_LEFLOAT:
return FILE_BEFLOAT;
case FILE_BEDOUBLE:
return FILE_LEDOUBLE;
case FILE_LEDOUBLE:
return FILE_BEDOUBLE;
default:
return type;
}
}
| DoS Exec Code | 0 | cvt_flip(int type, int flip)
{
if (flip == 0)
return type;
switch (type) {
case FILE_BESHORT:
return FILE_LESHORT;
case FILE_BELONG:
return FILE_LELONG;
case FILE_BEDATE:
return FILE_LEDATE;
case FILE_BELDATE:
return FILE_LELDATE;
case FILE_BEQUAD:
return FILE_LEQUAD;
case FILE_BEQDATE:
return FILE_LEQDATE;
case FILE_BEQLDATE:
return FILE_LEQLDATE;
case FILE_BEQWDATE:
return FILE_LEQWDATE;
case FILE_LESHORT:
return FILE_BESHORT;
case FILE_LELONG:
return FILE_BELONG;
case FILE_LEDATE:
return FILE_BEDATE;
case FILE_LELDATE:
return FILE_BELDATE;
case FILE_LEQUAD:
return FILE_BEQUAD;
case FILE_LEQDATE:
return FILE_BEQDATE;
case FILE_LEQLDATE:
return FILE_BEQLDATE;
case FILE_LEQWDATE:
return FILE_BEQWDATE;
case FILE_BEFLOAT:
return FILE_LEFLOAT;
case FILE_LEFLOAT:
return FILE_BEFLOAT;
case FILE_BEDOUBLE:
return FILE_LEDOUBLE;
case FILE_LEDOUBLE:
return FILE_BEDOUBLE;
default:
return type;
}
}
| @@ -1037,6 +1037,9 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
if (bytecnt > nbytes) {
bytecnt = nbytes;
}
+ if (offset > bytecnt) {
+ offset = bytecnt;
+ }
if (s == NULL) {
ms->search.s_len = 0;
ms->search.s = NULL; | CWE-20 | null | null |
11,902 | cvt_float(union VALUETYPE *p, const struct magic *m)
{
DO_CVT2(f, (float));
}
| DoS Exec Code | 0 | cvt_float(union VALUETYPE *p, const struct magic *m)
{
DO_CVT2(f, (float));
}
| @@ -1037,6 +1037,9 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
if (bytecnt > nbytes) {
bytecnt = nbytes;
}
+ if (offset > bytecnt) {
+ offset = bytecnt;
+ }
if (s == NULL) {
ms->search.s_len = 0;
ms->search.s = NULL; | CWE-20 | null | null |
11,903 | file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
size_t level, int mode, int text)
{
struct mlist *ml;
int rv, printed_something = 0, need_separator = 0;
for (ml = ms->mlist[0]->next; ml != ms->mlist[0]; ml = ml->next)
if ((rv = match(ms, ml->magic, ml->nmagic, buf, nbytes, 0, mode,
text, 0, level, &printed_something, &need_separator,
NULL)) != 0)
return rv;
return 0;
}
| DoS Exec Code | 0 | file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
size_t level, int mode, int text)
{
struct mlist *ml;
int rv, printed_something = 0, need_separator = 0;
for (ml = ms->mlist[0]->next; ml != ms->mlist[0]; ml = ml->next)
if ((rv = match(ms, ml->magic, ml->nmagic, buf, nbytes, 0, mode,
text, 0, level, &printed_something, &need_separator,
NULL)) != 0)
return rv;
return 0;
}
| @@ -1037,6 +1037,9 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
if (bytecnt > nbytes) {
bytecnt = nbytes;
}
+ if (offset > bytecnt) {
+ offset = bytecnt;
+ }
if (s == NULL) {
ms->search.s_len = 0;
ms->search.s = NULL; | CWE-20 | null | null |
11,904 | match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
const unsigned char *s, size_t nbytes, size_t offset, int mode, int text,
int flip, int recursion_level, int *printed_something, int *need_separator,
int *returnval)
{
uint32_t magindex = 0;
unsigned int cont_level = 0;
int returnvalv = 0, e; /* if a match is found it is set to 1*/
int firstline = 1; /* a flag to print X\n X\n- X */
int print = (ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0;
if (returnval == NULL)
returnval = &returnvalv;
if (file_check_mem(ms, cont_level) == -1)
return -1;
for (magindex = 0; magindex < nmagic; magindex++) {
int flush = 0;
struct magic *m = &magic[magindex];
if (m->type != FILE_NAME)
if ((IS_LIBMAGIC_STRING(m->type) &&
#define FLT (STRING_BINTEST | STRING_TEXTTEST)
((text && (m->str_flags & FLT) == STRING_BINTEST) ||
(!text && (m->str_flags & FLT) == STRING_TEXTTEST))) ||
(m->flag & mode) != mode) {
/* Skip sub-tests */
while (magindex + 1 < nmagic &&
magic[magindex + 1].cont_level != 0 &&
++magindex)
continue;
continue; /* Skip to next top-level test*/
}
ms->offset = m->offset;
ms->line = m->lineno;
/* if main entry matches, print it... */
switch (mget(ms, s, m, nbytes, offset, cont_level, mode, text,
flip, recursion_level + 1, printed_something,
need_separator, returnval)) {
case -1:
return -1;
case 0:
flush = m->reln != '!';
break;
default:
if (m->type == FILE_INDIRECT)
*returnval = 1;
switch (magiccheck(ms, m)) {
case -1:
return -1;
case 0:
flush++;
break;
default:
flush = 0;
break;
}
break;
}
if (flush) {
/*
* main entry didn't match,
* flush its continuations
*/
while (magindex < nmagic - 1 &&
magic[magindex + 1].cont_level != 0)
magindex++;
continue;
}
if ((e = handle_annotation(ms, m)) != 0) {
*returnval = 1;
return e;
}
/*
* If we are going to print something, we'll need to print
* a blank before we print something else.
*/
if (*m->desc) {
*need_separator = 1;
*printed_something = 1;
if (print_sep(ms, firstline) == -1)
return -1;
}
if (print && mprint(ms, m) == -1)
return -1;
ms->c.li[cont_level].off = moffset(ms, m);
/* and any continuations that match */
if (file_check_mem(ms, ++cont_level) == -1)
return -1;
while (magindex + 1 < nmagic && magic[magindex+1].cont_level != 0 &&
++magindex) {
m = &magic[magindex];
ms->line = m->lineno; /* for messages */
if (cont_level < m->cont_level)
continue;
if (cont_level > m->cont_level) {
/*
* We're at the end of the level
* "cont_level" continuations.
*/
cont_level = m->cont_level;
}
ms->offset = m->offset;
if (m->flag & OFFADD) {
ms->offset +=
ms->c.li[cont_level - 1].off;
}
#ifdef ENABLE_CONDITIONALS
if (m->cond == COND_ELSE ||
m->cond == COND_ELIF) {
if (ms->c.li[cont_level].last_match == 1)
continue;
}
#endif
switch (mget(ms, s, m, nbytes, offset, cont_level, mode,
text, flip, recursion_level + 1, printed_something,
need_separator, returnval)) {
case -1:
return -1;
case 0:
if (m->reln != '!')
continue;
flush = 1;
break;
default:
if (m->type == FILE_INDIRECT)
*returnval = 1;
flush = 0;
break;
}
switch (flush ? 1 : magiccheck(ms, m)) {
case -1:
return -1;
case 0:
#ifdef ENABLE_CONDITIONALS
ms->c.li[cont_level].last_match = 0;
#endif
break;
default:
#ifdef ENABLE_CONDITIONALS
ms->c.li[cont_level].last_match = 1;
#endif
if (m->type != FILE_DEFAULT)
ms->c.li[cont_level].got_match = 1;
else if (ms->c.li[cont_level].got_match) {
ms->c.li[cont_level].got_match = 0;
break;
}
if ((e = handle_annotation(ms, m)) != 0) {
*returnval = 1;
return e;
}
/*
* If we are going to print something,
* make sure that we have a separator first.
*/
if (*m->desc) {
if (!*printed_something) {
*printed_something = 1;
if (print_sep(ms, firstline)
== -1)
return -1;
}
}
/*
* This continuation matched. Print
* its message, with a blank before it
* if the previous item printed and
* this item isn't empty.
*/
/* space if previous printed */
if (*need_separator
&& ((m->flag & NOSPACE) == 0)
&& *m->desc) {
if (print &&
file_printf(ms, " ") == -1)
return -1;
*need_separator = 0;
}
if (print && mprint(ms, m) == -1)
return -1;
ms->c.li[cont_level].off = moffset(ms, m);
if (*m->desc)
*need_separator = 1;
/*
* If we see any continuations
* at a higher level,
* process them.
*/
if (file_check_mem(ms, ++cont_level) == -1)
return -1;
break;
}
}
if (*printed_something) {
firstline = 0;
if (print)
*returnval = 1;
}
if ((ms->flags & MAGIC_CONTINUE) == 0 && *printed_something) {
return *returnval; /* don't keep searching */
}
}
return *returnval; /* This is hit if -k is set or there is no match */
}
| DoS Exec Code | 0 | match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
const unsigned char *s, size_t nbytes, size_t offset, int mode, int text,
int flip, int recursion_level, int *printed_something, int *need_separator,
int *returnval)
{
uint32_t magindex = 0;
unsigned int cont_level = 0;
int returnvalv = 0, e; /* if a match is found it is set to 1*/
int firstline = 1; /* a flag to print X\n X\n- X */
int print = (ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0;
if (returnval == NULL)
returnval = &returnvalv;
if (file_check_mem(ms, cont_level) == -1)
return -1;
for (magindex = 0; magindex < nmagic; magindex++) {
int flush = 0;
struct magic *m = &magic[magindex];
if (m->type != FILE_NAME)
if ((IS_LIBMAGIC_STRING(m->type) &&
#define FLT (STRING_BINTEST | STRING_TEXTTEST)
((text && (m->str_flags & FLT) == STRING_BINTEST) ||
(!text && (m->str_flags & FLT) == STRING_TEXTTEST))) ||
(m->flag & mode) != mode) {
/* Skip sub-tests */
while (magindex + 1 < nmagic &&
magic[magindex + 1].cont_level != 0 &&
++magindex)
continue;
continue; /* Skip to next top-level test*/
}
ms->offset = m->offset;
ms->line = m->lineno;
/* if main entry matches, print it... */
switch (mget(ms, s, m, nbytes, offset, cont_level, mode, text,
flip, recursion_level + 1, printed_something,
need_separator, returnval)) {
case -1:
return -1;
case 0:
flush = m->reln != '!';
break;
default:
if (m->type == FILE_INDIRECT)
*returnval = 1;
switch (magiccheck(ms, m)) {
case -1:
return -1;
case 0:
flush++;
break;
default:
flush = 0;
break;
}
break;
}
if (flush) {
/*
* main entry didn't match,
* flush its continuations
*/
while (magindex < nmagic - 1 &&
magic[magindex + 1].cont_level != 0)
magindex++;
continue;
}
if ((e = handle_annotation(ms, m)) != 0) {
*returnval = 1;
return e;
}
/*
* If we are going to print something, we'll need to print
* a blank before we print something else.
*/
if (*m->desc) {
*need_separator = 1;
*printed_something = 1;
if (print_sep(ms, firstline) == -1)
return -1;
}
if (print && mprint(ms, m) == -1)
return -1;
ms->c.li[cont_level].off = moffset(ms, m);
/* and any continuations that match */
if (file_check_mem(ms, ++cont_level) == -1)
return -1;
while (magindex + 1 < nmagic && magic[magindex+1].cont_level != 0 &&
++magindex) {
m = &magic[magindex];
ms->line = m->lineno; /* for messages */
if (cont_level < m->cont_level)
continue;
if (cont_level > m->cont_level) {
/*
* We're at the end of the level
* "cont_level" continuations.
*/
cont_level = m->cont_level;
}
ms->offset = m->offset;
if (m->flag & OFFADD) {
ms->offset +=
ms->c.li[cont_level - 1].off;
}
#ifdef ENABLE_CONDITIONALS
if (m->cond == COND_ELSE ||
m->cond == COND_ELIF) {
if (ms->c.li[cont_level].last_match == 1)
continue;
}
#endif
switch (mget(ms, s, m, nbytes, offset, cont_level, mode,
text, flip, recursion_level + 1, printed_something,
need_separator, returnval)) {
case -1:
return -1;
case 0:
if (m->reln != '!')
continue;
flush = 1;
break;
default:
if (m->type == FILE_INDIRECT)
*returnval = 1;
flush = 0;
break;
}
switch (flush ? 1 : magiccheck(ms, m)) {
case -1:
return -1;
case 0:
#ifdef ENABLE_CONDITIONALS
ms->c.li[cont_level].last_match = 0;
#endif
break;
default:
#ifdef ENABLE_CONDITIONALS
ms->c.li[cont_level].last_match = 1;
#endif
if (m->type != FILE_DEFAULT)
ms->c.li[cont_level].got_match = 1;
else if (ms->c.li[cont_level].got_match) {
ms->c.li[cont_level].got_match = 0;
break;
}
if ((e = handle_annotation(ms, m)) != 0) {
*returnval = 1;
return e;
}
/*
* If we are going to print something,
* make sure that we have a separator first.
*/
if (*m->desc) {
if (!*printed_something) {
*printed_something = 1;
if (print_sep(ms, firstline)
== -1)
return -1;
}
}
/*
* This continuation matched. Print
* its message, with a blank before it
* if the previous item printed and
* this item isn't empty.
*/
/* space if previous printed */
if (*need_separator
&& ((m->flag & NOSPACE) == 0)
&& *m->desc) {
if (print &&
file_printf(ms, " ") == -1)
return -1;
*need_separator = 0;
}
if (print && mprint(ms, m) == -1)
return -1;
ms->c.li[cont_level].off = moffset(ms, m);
if (*m->desc)
*need_separator = 1;
/*
* If we see any continuations
* at a higher level,
* process them.
*/
if (file_check_mem(ms, ++cont_level) == -1)
return -1;
break;
}
}
if (*printed_something) {
firstline = 0;
if (print)
*returnval = 1;
}
if ((ms->flags & MAGIC_CONTINUE) == 0 && *printed_something) {
return *returnval; /* don't keep searching */
}
}
return *returnval; /* This is hit if -k is set or there is no match */
}
| @@ -1037,6 +1037,9 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
if (bytecnt > nbytes) {
bytecnt = nbytes;
}
+ if (offset > bytecnt) {
+ offset = bytecnt;
+ }
if (s == NULL) {
ms->search.s_len = 0;
ms->search.s = NULL; | CWE-20 | null | null |
11,905 | mconvert(struct magic_set *ms, struct magic *m, int flip)
{
union VALUETYPE *p = &ms->ms_value;
switch (cvt_flip(m->type, flip)) {
case FILE_BYTE:
cvt_8(p, m);
return 1;
case FILE_SHORT:
cvt_16(p, m);
return 1;
case FILE_LONG:
case FILE_DATE:
case FILE_LDATE:
cvt_32(p, m);
return 1;
case FILE_QUAD:
case FILE_QDATE:
case FILE_QLDATE:
case FILE_QWDATE:
cvt_64(p, m);
return 1;
case FILE_STRING:
case FILE_BESTRING16:
case FILE_LESTRING16: {
/* Null terminate and eat *trailing* return */
p->s[sizeof(p->s) - 1] = '\0';
return 1;
}
case FILE_PSTRING: {
size_t sz = file_pstring_length_size(m);
char *ptr1 = p->s, *ptr2 = ptr1 + sz;
size_t len = file_pstring_get_length(m, ptr1);
sz = sizeof(p->s) - sz; /* maximum length of string */
if (len >= sz) {
/*
* The size of the pascal string length (sz)
* is 1, 2, or 4. We need at least 1 byte for NUL
* termination, but we've already truncated the
* string by p->s, so we need to deduct sz.
* Because we can use one of the bytes of the length
* after we shifted as NUL termination.
*/
len = sz;
}
while (len--)
*ptr1++ = *ptr2++;
*ptr1 = '\0';
return 1;
}
case FILE_BESHORT:
p->h = (short)((p->hs[0]<<8)|(p->hs[1]));
cvt_16(p, m);
return 1;
case FILE_BELONG:
case FILE_BEDATE:
case FILE_BELDATE:
p->l = (int32_t)
((p->hl[0]<<24)|(p->hl[1]<<16)|(p->hl[2]<<8)|(p->hl[3]));
cvt_32(p, m);
return 1;
case FILE_BEQUAD:
case FILE_BEQDATE:
case FILE_BEQLDATE:
case FILE_BEQWDATE:
p->q = (uint64_t)
(((uint64_t)p->hq[0]<<56)|((uint64_t)p->hq[1]<<48)|
((uint64_t)p->hq[2]<<40)|((uint64_t)p->hq[3]<<32)|
((uint64_t)p->hq[4]<<24)|((uint64_t)p->hq[5]<<16)|
((uint64_t)p->hq[6]<<8)|((uint64_t)p->hq[7]));
cvt_64(p, m);
return 1;
case FILE_LESHORT:
p->h = (short)((p->hs[1]<<8)|(p->hs[0]));
cvt_16(p, m);
return 1;
case FILE_LELONG:
case FILE_LEDATE:
case FILE_LELDATE:
p->l = (int32_t)
((p->hl[3]<<24)|(p->hl[2]<<16)|(p->hl[1]<<8)|(p->hl[0]));
cvt_32(p, m);
return 1;
case FILE_LEQUAD:
case FILE_LEQDATE:
case FILE_LEQLDATE:
case FILE_LEQWDATE:
p->q = (uint64_t)
(((uint64_t)p->hq[7]<<56)|((uint64_t)p->hq[6]<<48)|
((uint64_t)p->hq[5]<<40)|((uint64_t)p->hq[4]<<32)|
((uint64_t)p->hq[3]<<24)|((uint64_t)p->hq[2]<<16)|
((uint64_t)p->hq[1]<<8)|((uint64_t)p->hq[0]));
cvt_64(p, m);
return 1;
case FILE_MELONG:
case FILE_MEDATE:
case FILE_MELDATE:
p->l = (int32_t)
((p->hl[1]<<24)|(p->hl[0]<<16)|(p->hl[3]<<8)|(p->hl[2]));
cvt_32(p, m);
return 1;
case FILE_FLOAT:
cvt_float(p, m);
return 1;
case FILE_BEFLOAT:
p->l = ((uint32_t)p->hl[0]<<24)|((uint32_t)p->hl[1]<<16)|
((uint32_t)p->hl[2]<<8) |((uint32_t)p->hl[3]);
cvt_float(p, m);
return 1;
case FILE_LEFLOAT:
p->l = ((uint32_t)p->hl[3]<<24)|((uint32_t)p->hl[2]<<16)|
((uint32_t)p->hl[1]<<8) |((uint32_t)p->hl[0]);
cvt_float(p, m);
return 1;
case FILE_DOUBLE:
cvt_double(p, m);
return 1;
case FILE_BEDOUBLE:
p->q = ((uint64_t)p->hq[0]<<56)|((uint64_t)p->hq[1]<<48)|
((uint64_t)p->hq[2]<<40)|((uint64_t)p->hq[3]<<32)|
((uint64_t)p->hq[4]<<24)|((uint64_t)p->hq[5]<<16)|
((uint64_t)p->hq[6]<<8) |((uint64_t)p->hq[7]);
cvt_double(p, m);
return 1;
case FILE_LEDOUBLE:
p->q = ((uint64_t)p->hq[7]<<56)|((uint64_t)p->hq[6]<<48)|
((uint64_t)p->hq[5]<<40)|((uint64_t)p->hq[4]<<32)|
((uint64_t)p->hq[3]<<24)|((uint64_t)p->hq[2]<<16)|
((uint64_t)p->hq[1]<<8) |((uint64_t)p->hq[0]);
cvt_double(p, m);
return 1;
case FILE_REGEX:
case FILE_SEARCH:
case FILE_DEFAULT:
case FILE_NAME:
case FILE_USE:
return 1;
default:
file_magerror(ms, "invalid type %d in mconvert()", m->type);
return 0;
}
}
| DoS Exec Code | 0 | mconvert(struct magic_set *ms, struct magic *m, int flip)
{
union VALUETYPE *p = &ms->ms_value;
switch (cvt_flip(m->type, flip)) {
case FILE_BYTE:
cvt_8(p, m);
return 1;
case FILE_SHORT:
cvt_16(p, m);
return 1;
case FILE_LONG:
case FILE_DATE:
case FILE_LDATE:
cvt_32(p, m);
return 1;
case FILE_QUAD:
case FILE_QDATE:
case FILE_QLDATE:
case FILE_QWDATE:
cvt_64(p, m);
return 1;
case FILE_STRING:
case FILE_BESTRING16:
case FILE_LESTRING16: {
/* Null terminate and eat *trailing* return */
p->s[sizeof(p->s) - 1] = '\0';
return 1;
}
case FILE_PSTRING: {
size_t sz = file_pstring_length_size(m);
char *ptr1 = p->s, *ptr2 = ptr1 + sz;
size_t len = file_pstring_get_length(m, ptr1);
sz = sizeof(p->s) - sz; /* maximum length of string */
if (len >= sz) {
/*
* The size of the pascal string length (sz)
* is 1, 2, or 4. We need at least 1 byte for NUL
* termination, but we've already truncated the
* string by p->s, so we need to deduct sz.
* Because we can use one of the bytes of the length
* after we shifted as NUL termination.
*/
len = sz;
}
while (len--)
*ptr1++ = *ptr2++;
*ptr1 = '\0';
return 1;
}
case FILE_BESHORT:
p->h = (short)((p->hs[0]<<8)|(p->hs[1]));
cvt_16(p, m);
return 1;
case FILE_BELONG:
case FILE_BEDATE:
case FILE_BELDATE:
p->l = (int32_t)
((p->hl[0]<<24)|(p->hl[1]<<16)|(p->hl[2]<<8)|(p->hl[3]));
cvt_32(p, m);
return 1;
case FILE_BEQUAD:
case FILE_BEQDATE:
case FILE_BEQLDATE:
case FILE_BEQWDATE:
p->q = (uint64_t)
(((uint64_t)p->hq[0]<<56)|((uint64_t)p->hq[1]<<48)|
((uint64_t)p->hq[2]<<40)|((uint64_t)p->hq[3]<<32)|
((uint64_t)p->hq[4]<<24)|((uint64_t)p->hq[5]<<16)|
((uint64_t)p->hq[6]<<8)|((uint64_t)p->hq[7]));
cvt_64(p, m);
return 1;
case FILE_LESHORT:
p->h = (short)((p->hs[1]<<8)|(p->hs[0]));
cvt_16(p, m);
return 1;
case FILE_LELONG:
case FILE_LEDATE:
case FILE_LELDATE:
p->l = (int32_t)
((p->hl[3]<<24)|(p->hl[2]<<16)|(p->hl[1]<<8)|(p->hl[0]));
cvt_32(p, m);
return 1;
case FILE_LEQUAD:
case FILE_LEQDATE:
case FILE_LEQLDATE:
case FILE_LEQWDATE:
p->q = (uint64_t)
(((uint64_t)p->hq[7]<<56)|((uint64_t)p->hq[6]<<48)|
((uint64_t)p->hq[5]<<40)|((uint64_t)p->hq[4]<<32)|
((uint64_t)p->hq[3]<<24)|((uint64_t)p->hq[2]<<16)|
((uint64_t)p->hq[1]<<8)|((uint64_t)p->hq[0]));
cvt_64(p, m);
return 1;
case FILE_MELONG:
case FILE_MEDATE:
case FILE_MELDATE:
p->l = (int32_t)
((p->hl[1]<<24)|(p->hl[0]<<16)|(p->hl[3]<<8)|(p->hl[2]));
cvt_32(p, m);
return 1;
case FILE_FLOAT:
cvt_float(p, m);
return 1;
case FILE_BEFLOAT:
p->l = ((uint32_t)p->hl[0]<<24)|((uint32_t)p->hl[1]<<16)|
((uint32_t)p->hl[2]<<8) |((uint32_t)p->hl[3]);
cvt_float(p, m);
return 1;
case FILE_LEFLOAT:
p->l = ((uint32_t)p->hl[3]<<24)|((uint32_t)p->hl[2]<<16)|
((uint32_t)p->hl[1]<<8) |((uint32_t)p->hl[0]);
cvt_float(p, m);
return 1;
case FILE_DOUBLE:
cvt_double(p, m);
return 1;
case FILE_BEDOUBLE:
p->q = ((uint64_t)p->hq[0]<<56)|((uint64_t)p->hq[1]<<48)|
((uint64_t)p->hq[2]<<40)|((uint64_t)p->hq[3]<<32)|
((uint64_t)p->hq[4]<<24)|((uint64_t)p->hq[5]<<16)|
((uint64_t)p->hq[6]<<8) |((uint64_t)p->hq[7]);
cvt_double(p, m);
return 1;
case FILE_LEDOUBLE:
p->q = ((uint64_t)p->hq[7]<<56)|((uint64_t)p->hq[6]<<48)|
((uint64_t)p->hq[5]<<40)|((uint64_t)p->hq[4]<<32)|
((uint64_t)p->hq[3]<<24)|((uint64_t)p->hq[2]<<16)|
((uint64_t)p->hq[1]<<8) |((uint64_t)p->hq[0]);
cvt_double(p, m);
return 1;
case FILE_REGEX:
case FILE_SEARCH:
case FILE_DEFAULT:
case FILE_NAME:
case FILE_USE:
return 1;
default:
file_magerror(ms, "invalid type %d in mconvert()", m->type);
return 0;
}
}
| @@ -1037,6 +1037,9 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
if (bytecnt > nbytes) {
bytecnt = nbytes;
}
+ if (offset > bytecnt) {
+ offset = bytecnt;
+ }
if (s == NULL) {
ms->search.s_len = 0;
ms->search.s = NULL; | CWE-20 | null | null |
11,906 | static zval *incomplete_class_get_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) /* {{{ */
{
incomplete_class_message(object, E_NOTICE TSRMLS_CC);
if (type == BP_VAR_W || type == BP_VAR_RW) {
return EG(error_zval_ptr);
} else {
return EG(uninitialized_zval_ptr);
}
}
/* }}} */
| DoS Exec Code | 0 | static zval *incomplete_class_get_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) /* {{{ */
{
incomplete_class_message(object, E_NOTICE TSRMLS_CC);
if (type == BP_VAR_W || type == BP_VAR_RW) {
return EG(error_zval_ptr);
} else {
return EG(uninitialized_zval_ptr);
}
}
/* }}} */
| @@ -144,7 +144,7 @@ PHPAPI char *php_lookup_class_name(zval *object, zend_uint *nlen)
object_properties = Z_OBJPROP_P(object);
- if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS) {
+ if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS && Z_TYPE_PP(val) == IS_STRING) {
retval = estrndup(Z_STRVAL_PP(val), Z_STRLEN_PP(val));
if (nlen) { | null | null | null |
11,907 | static zval **incomplete_class_get_property_ptr_ptr(zval *object, zval *member, const zend_literal *key TSRMLS_DC) /* {{{ */
{
incomplete_class_message(object, E_NOTICE TSRMLS_CC);
return &EG(error_zval_ptr);
}
/* }}} */
| DoS Exec Code | 0 | static zval **incomplete_class_get_property_ptr_ptr(zval *object, zval *member, const zend_literal *key TSRMLS_DC) /* {{{ */
{
incomplete_class_message(object, E_NOTICE TSRMLS_CC);
return &EG(error_zval_ptr);
}
/* }}} */
| @@ -144,7 +144,7 @@ PHPAPI char *php_lookup_class_name(zval *object, zend_uint *nlen)
object_properties = Z_OBJPROP_P(object);
- if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS) {
+ if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS && Z_TYPE_PP(val) == IS_STRING) {
retval = estrndup(Z_STRVAL_PP(val), Z_STRLEN_PP(val));
if (nlen) { | null | null | null |
11,908 | static int incomplete_class_has_property(zval *object, zval *member, int check_empty, const zend_literal *key TSRMLS_DC) /* {{{ */
{
incomplete_class_message(object, E_NOTICE TSRMLS_CC);
return 0;
}
/* }}} */
| DoS Exec Code | 0 | static int incomplete_class_has_property(zval *object, zval *member, int check_empty, const zend_literal *key TSRMLS_DC) /* {{{ */
{
incomplete_class_message(object, E_NOTICE TSRMLS_CC);
return 0;
}
/* }}} */
| @@ -144,7 +144,7 @@ PHPAPI char *php_lookup_class_name(zval *object, zend_uint *nlen)
object_properties = Z_OBJPROP_P(object);
- if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS) {
+ if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS && Z_TYPE_PP(val) == IS_STRING) {
retval = estrndup(Z_STRVAL_PP(val), Z_STRLEN_PP(val));
if (nlen) { | null | null | null |
11,909 | static void incomplete_class_message(zval *object, int error_type TSRMLS_DC)
{
char *class_name;
zend_bool class_name_alloced = 1;
class_name = php_lookup_class_name(object, NULL);
if (!class_name) {
class_name_alloced = 0;
class_name = "unknown";
}
php_error_docref(NULL TSRMLS_CC, error_type, INCOMPLETE_CLASS_MSG, class_name);
if (class_name_alloced) {
efree(class_name);
}
}
| DoS Exec Code | 0 | static void incomplete_class_message(zval *object, int error_type TSRMLS_DC)
{
char *class_name;
zend_bool class_name_alloced = 1;
class_name = php_lookup_class_name(object, NULL);
if (!class_name) {
class_name_alloced = 0;
class_name = "unknown";
}
php_error_docref(NULL TSRMLS_CC, error_type, INCOMPLETE_CLASS_MSG, class_name);
if (class_name_alloced) {
efree(class_name);
}
}
| @@ -144,7 +144,7 @@ PHPAPI char *php_lookup_class_name(zval *object, zend_uint *nlen)
object_properties = Z_OBJPROP_P(object);
- if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS) {
+ if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS && Z_TYPE_PP(val) == IS_STRING) {
retval = estrndup(Z_STRVAL_PP(val), Z_STRLEN_PP(val));
if (nlen) { | null | null | null |
11,910 | static void incomplete_class_unset_property(zval *object, zval *member, const zend_literal *key TSRMLS_DC) /* {{{ */
{
incomplete_class_message(object, E_NOTICE TSRMLS_CC);
}
/* }}} */
| DoS Exec Code | 0 | static void incomplete_class_unset_property(zval *object, zval *member, const zend_literal *key TSRMLS_DC) /* {{{ */
{
incomplete_class_message(object, E_NOTICE TSRMLS_CC);
}
/* }}} */
| @@ -144,7 +144,7 @@ PHPAPI char *php_lookup_class_name(zval *object, zend_uint *nlen)
object_properties = Z_OBJPROP_P(object);
- if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS) {
+ if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS && Z_TYPE_PP(val) == IS_STRING) {
retval = estrndup(Z_STRVAL_PP(val), Z_STRLEN_PP(val));
if (nlen) { | null | null | null |
11,911 | static void incomplete_class_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC) /* {{{ */
{
incomplete_class_message(object, E_NOTICE TSRMLS_CC);
}
/* }}} */
| DoS Exec Code | 0 | static void incomplete_class_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC) /* {{{ */
{
incomplete_class_message(object, E_NOTICE TSRMLS_CC);
}
/* }}} */
| @@ -144,7 +144,7 @@ PHPAPI char *php_lookup_class_name(zval *object, zend_uint *nlen)
object_properties = Z_OBJPROP_P(object);
- if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS) {
+ if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS && Z_TYPE_PP(val) == IS_STRING) {
retval = estrndup(Z_STRVAL_PP(val), Z_STRLEN_PP(val));
if (nlen) { | null | null | null |
11,912 | PHPAPI zend_class_entry *php_create_incomplete_class(TSRMLS_D)
{
zend_class_entry incomplete_class;
INIT_CLASS_ENTRY(incomplete_class, INCOMPLETE_CLASS, NULL);
incomplete_class.create_object = php_create_incomplete_object;
memcpy(&php_incomplete_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
php_incomplete_object_handlers.read_property = incomplete_class_get_property;
php_incomplete_object_handlers.has_property = incomplete_class_has_property;
php_incomplete_object_handlers.unset_property = incomplete_class_unset_property;
php_incomplete_object_handlers.write_property = incomplete_class_write_property;
php_incomplete_object_handlers.get_property_ptr_ptr = incomplete_class_get_property_ptr_ptr;
php_incomplete_object_handlers.get_method = incomplete_class_get_method;
return zend_register_internal_class(&incomplete_class TSRMLS_CC);
}
| DoS Exec Code | 0 | PHPAPI zend_class_entry *php_create_incomplete_class(TSRMLS_D)
{
zend_class_entry incomplete_class;
INIT_CLASS_ENTRY(incomplete_class, INCOMPLETE_CLASS, NULL);
incomplete_class.create_object = php_create_incomplete_object;
memcpy(&php_incomplete_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
php_incomplete_object_handlers.read_property = incomplete_class_get_property;
php_incomplete_object_handlers.has_property = incomplete_class_has_property;
php_incomplete_object_handlers.unset_property = incomplete_class_unset_property;
php_incomplete_object_handlers.write_property = incomplete_class_write_property;
php_incomplete_object_handlers.get_property_ptr_ptr = incomplete_class_get_property_ptr_ptr;
php_incomplete_object_handlers.get_method = incomplete_class_get_method;
return zend_register_internal_class(&incomplete_class TSRMLS_CC);
}
| @@ -144,7 +144,7 @@ PHPAPI char *php_lookup_class_name(zval *object, zend_uint *nlen)
object_properties = Z_OBJPROP_P(object);
- if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS) {
+ if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS && Z_TYPE_PP(val) == IS_STRING) {
retval = estrndup(Z_STRVAL_PP(val), Z_STRLEN_PP(val));
if (nlen) { | null | null | null |
11,913 | static zend_object_value php_create_incomplete_object(zend_class_entry *class_type TSRMLS_DC)
{
zend_object *object;
zend_object_value value;
value = zend_objects_new(&object, class_type TSRMLS_CC);
value.handlers = &php_incomplete_object_handlers;
object_properties_init(object, class_type);
return value;
}
| DoS Exec Code | 0 | static zend_object_value php_create_incomplete_object(zend_class_entry *class_type TSRMLS_DC)
{
zend_object *object;
zend_object_value value;
value = zend_objects_new(&object, class_type TSRMLS_CC);
value.handlers = &php_incomplete_object_handlers;
object_properties_init(object, class_type);
return value;
}
| @@ -144,7 +144,7 @@ PHPAPI char *php_lookup_class_name(zval *object, zend_uint *nlen)
object_properties = Z_OBJPROP_P(object);
- if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS) {
+ if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS && Z_TYPE_PP(val) == IS_STRING) {
retval = estrndup(Z_STRVAL_PP(val), Z_STRLEN_PP(val));
if (nlen) { | null | null | null |
11,914 | PHPAPI void php_store_class_name(zval *object, const char *name, zend_uint len)
{
zval *val;
TSRMLS_FETCH();
MAKE_STD_ZVAL(val);
Z_TYPE_P(val) = IS_STRING;
Z_STRVAL_P(val) = estrndup(name, len);
Z_STRLEN_P(val) = len;
zend_hash_update(Z_OBJPROP_P(object), MAGIC_MEMBER, sizeof(MAGIC_MEMBER), &val, sizeof(val), NULL);
}
| DoS Exec Code | 0 | PHPAPI void php_store_class_name(zval *object, const char *name, zend_uint len)
{
zval *val;
TSRMLS_FETCH();
MAKE_STD_ZVAL(val);
Z_TYPE_P(val) = IS_STRING;
Z_STRVAL_P(val) = estrndup(name, len);
Z_STRLEN_P(val) = len;
zend_hash_update(Z_OBJPROP_P(object), MAGIC_MEMBER, sizeof(MAGIC_MEMBER), &val, sizeof(val), NULL);
}
| @@ -144,7 +144,7 @@ PHPAPI char *php_lookup_class_name(zval *object, zend_uint *nlen)
object_properties = Z_OBJPROP_P(object);
- if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS) {
+ if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS && Z_TYPE_PP(val) == IS_STRING) {
retval = estrndup(Z_STRVAL_PP(val), Z_STRLEN_PP(val));
if (nlen) { | null | null | null |
11,915 | static inline int array_num_elements(HashTable* ht)
{
if (ht->pListTail && ht->pListTail->nKeyLength == 0) {
return ht->pListTail->h-1;
}
return 0;
}
| DoS Exec Code | 0 | static inline int array_num_elements(HashTable* ht)
{
if (ht->pListTail && ht->pListTail->nKeyLength == 0) {
return ht->pListTail->h-1;
}
return 0;
}
| @@ -3649,18 +3649,21 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type TS
Z_OBJCE_PP(tmp) == soap_var_class_entry) {
zval **ztype;
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE ||
+ Z_TYPE_PP(ztype) != IS_LONG) {
soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property");
}
cur_type = Z_LVAL_PP(ztype);
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_stype", sizeof("enc_stype"), (void **)&ztype) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_stype", sizeof("enc_stype"), (void **)&ztype) == SUCCESS &&
+ Z_TYPE_PP(ztype) == IS_STRING) {
cur_stype = Z_STRVAL_PP(ztype);
} else {
cur_stype = NULL;
}
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_ns", sizeof("enc_ns"), (void **)&ztype) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_ns", sizeof("enc_ns"), (void **)&ztype) == SUCCESS &&
+ Z_TYPE_PP(ztype) == IS_STRING) {
cur_ns = Z_STRVAL_PP(ztype);
} else {
cur_ns = NULL; | null | null | null |
11,916 | static int calc_dimension(const char* str)
{
int i = 1;
while (*str != ']' && *str != '\0') {
if (*str == ',') {
i++;
}
str++;
}
return i;
}
| DoS Exec Code | 0 | static int calc_dimension(const char* str)
{
int i = 1;
while (*str != ']' && *str != '\0') {
if (*str == ',') {
i++;
}
str++;
}
return i;
}
| @@ -3649,18 +3649,21 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type TS
Z_OBJCE_PP(tmp) == soap_var_class_entry) {
zval **ztype;
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE ||
+ Z_TYPE_PP(ztype) != IS_LONG) {
soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property");
}
cur_type = Z_LVAL_PP(ztype);
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_stype", sizeof("enc_stype"), (void **)&ztype) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_stype", sizeof("enc_stype"), (void **)&ztype) == SUCCESS &&
+ Z_TYPE_PP(ztype) == IS_STRING) {
cur_stype = Z_STRVAL_PP(ztype);
} else {
cur_stype = NULL;
}
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_ns", sizeof("enc_ns"), (void **)&ztype) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_ns", sizeof("enc_ns"), (void **)&ztype) == SUCCESS &&
+ Z_TYPE_PP(ztype) == IS_STRING) {
cur_ns = Z_STRVAL_PP(ztype);
} else {
cur_ns = NULL; | null | null | null |
11,917 | static int calc_dimension_12(const char* str)
{
int i = 0, flag = 0;
while (*str != '\0' && (*str < '0' || *str > '9') && (*str != '*')) {
str++;
}
if (*str == '*') {
i++;
str++;
}
while (*str != '\0') {
if (*str >= '0' && *str <= '9') {
if (flag == 0) {
i++;
flag = 1;
}
} else if (*str == '*') {
soap_error0(E_ERROR, "Encoding: '*' may only be first arraySize value in list");
} else {
flag = 0;
}
str++;
}
return i;
}
| DoS Exec Code | 0 | static int calc_dimension_12(const char* str)
{
int i = 0, flag = 0;
while (*str != '\0' && (*str < '0' || *str > '9') && (*str != '*')) {
str++;
}
if (*str == '*') {
i++;
str++;
}
while (*str != '\0') {
if (*str >= '0' && *str <= '9') {
if (flag == 0) {
i++;
flag = 1;
}
} else if (*str == '*') {
soap_error0(E_ERROR, "Encoding: '*' may only be first arraySize value in list");
} else {
flag = 0;
}
str++;
}
return i;
}
| @@ -3649,18 +3649,21 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type TS
Z_OBJCE_PP(tmp) == soap_var_class_entry) {
zval **ztype;
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE ||
+ Z_TYPE_PP(ztype) != IS_LONG) {
soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property");
}
cur_type = Z_LVAL_PP(ztype);
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_stype", sizeof("enc_stype"), (void **)&ztype) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_stype", sizeof("enc_stype"), (void **)&ztype) == SUCCESS &&
+ Z_TYPE_PP(ztype) == IS_STRING) {
cur_stype = Z_STRVAL_PP(ztype);
} else {
cur_stype = NULL;
}
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_ns", sizeof("enc_ns"), (void **)&ztype) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_ns", sizeof("enc_ns"), (void **)&ztype) == SUCCESS &&
+ Z_TYPE_PP(ztype) == IS_STRING) {
cur_ns = Z_STRVAL_PP(ztype);
} else {
cur_ns = NULL; | null | null | null |
11,918 | xmlNsPtr encode_add_ns(xmlNodePtr node, const char* ns)
{
xmlNsPtr xmlns;
if (ns == NULL) {
return NULL;
}
xmlns = xmlSearchNsByHref(node->doc, node, BAD_CAST(ns));
if (xmlns != NULL && xmlns->prefix == NULL) {
xmlns = xmlSearchNsPrefixByHref(node->doc, node, BAD_CAST(ns));
}
if (xmlns == NULL) {
xmlChar* prefix;
TSRMLS_FETCH();
if (zend_hash_find(&SOAP_GLOBAL(defEncNs), (char*)ns, strlen(ns) + 1, (void **)&prefix) == SUCCESS) {
xmlns = xmlNewNs(node->doc->children, BAD_CAST(ns), prefix);
} else {
smart_str prefix = {0};
int num = ++SOAP_GLOBAL(cur_uniq_ns);
while (1) {
smart_str_appendl(&prefix, "ns", 2);
smart_str_append_long(&prefix, num);
smart_str_0(&prefix);
if (xmlSearchNs(node->doc, node, BAD_CAST(prefix.c)) == NULL) {
break;
}
smart_str_free(&prefix);
prefix.c = NULL;
prefix.len = 0;
num = ++SOAP_GLOBAL(cur_uniq_ns);
}
xmlns = xmlNewNs(node->doc->children, BAD_CAST(ns), BAD_CAST(prefix.c));
smart_str_free(&prefix);
}
}
return xmlns;
}
| DoS Exec Code | 0 | xmlNsPtr encode_add_ns(xmlNodePtr node, const char* ns)
{
xmlNsPtr xmlns;
if (ns == NULL) {
return NULL;
}
xmlns = xmlSearchNsByHref(node->doc, node, BAD_CAST(ns));
if (xmlns != NULL && xmlns->prefix == NULL) {
xmlns = xmlSearchNsPrefixByHref(node->doc, node, BAD_CAST(ns));
}
if (xmlns == NULL) {
xmlChar* prefix;
TSRMLS_FETCH();
if (zend_hash_find(&SOAP_GLOBAL(defEncNs), (char*)ns, strlen(ns) + 1, (void **)&prefix) == SUCCESS) {
xmlns = xmlNewNs(node->doc->children, BAD_CAST(ns), prefix);
} else {
smart_str prefix = {0};
int num = ++SOAP_GLOBAL(cur_uniq_ns);
while (1) {
smart_str_appendl(&prefix, "ns", 2);
smart_str_append_long(&prefix, num);
smart_str_0(&prefix);
if (xmlSearchNs(node->doc, node, BAD_CAST(prefix.c)) == NULL) {
break;
}
smart_str_free(&prefix);
prefix.c = NULL;
prefix.len = 0;
num = ++SOAP_GLOBAL(cur_uniq_ns);
}
xmlns = xmlNewNs(node->doc->children, BAD_CAST(ns), BAD_CAST(prefix.c));
smart_str_free(&prefix);
}
}
return xmlns;
}
| @@ -3649,18 +3649,21 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type TS
Z_OBJCE_PP(tmp) == soap_var_class_entry) {
zval **ztype;
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE ||
+ Z_TYPE_PP(ztype) != IS_LONG) {
soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property");
}
cur_type = Z_LVAL_PP(ztype);
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_stype", sizeof("enc_stype"), (void **)&ztype) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_stype", sizeof("enc_stype"), (void **)&ztype) == SUCCESS &&
+ Z_TYPE_PP(ztype) == IS_STRING) {
cur_stype = Z_STRVAL_PP(ztype);
} else {
cur_stype = NULL;
}
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_ns", sizeof("enc_ns"), (void **)&ztype) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_ns", sizeof("enc_ns"), (void **)&ztype) == SUCCESS &&
+ Z_TYPE_PP(ztype) == IS_STRING) {
cur_ns = Z_STRVAL_PP(ztype);
} else {
cur_ns = NULL; | null | null | null |
11,919 | void encode_finish()
{
TSRMLS_FETCH();
SOAP_GLOBAL(cur_uniq_ns) = 0;
SOAP_GLOBAL(cur_uniq_ref) = 0;
if (SOAP_GLOBAL(ref_map)) {
zend_hash_destroy(SOAP_GLOBAL(ref_map));
efree(SOAP_GLOBAL(ref_map));
SOAP_GLOBAL(ref_map) = NULL;
}
}
| DoS Exec Code | 0 | void encode_finish()
{
TSRMLS_FETCH();
SOAP_GLOBAL(cur_uniq_ns) = 0;
SOAP_GLOBAL(cur_uniq_ref) = 0;
if (SOAP_GLOBAL(ref_map)) {
zend_hash_destroy(SOAP_GLOBAL(ref_map));
efree(SOAP_GLOBAL(ref_map));
SOAP_GLOBAL(ref_map) = NULL;
}
}
| @@ -3649,18 +3649,21 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type TS
Z_OBJCE_PP(tmp) == soap_var_class_entry) {
zval **ztype;
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE ||
+ Z_TYPE_PP(ztype) != IS_LONG) {
soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property");
}
cur_type = Z_LVAL_PP(ztype);
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_stype", sizeof("enc_stype"), (void **)&ztype) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_stype", sizeof("enc_stype"), (void **)&ztype) == SUCCESS &&
+ Z_TYPE_PP(ztype) == IS_STRING) {
cur_stype = Z_STRVAL_PP(ztype);
} else {
cur_stype = NULL;
}
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_ns", sizeof("enc_ns"), (void **)&ztype) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_ns", sizeof("enc_ns"), (void **)&ztype) == SUCCESS &&
+ Z_TYPE_PP(ztype) == IS_STRING) {
cur_ns = Z_STRVAL_PP(ztype);
} else {
cur_ns = NULL; | null | null | null |
11,920 | static encodePtr find_encoder_by_type_name(sdlPtr sdl, const char *type)
{
if (sdl && sdl->encoders) {
HashPosition pos;
encodePtr *enc;
for (zend_hash_internal_pointer_reset_ex(sdl->encoders, &pos);
zend_hash_get_current_data_ex(sdl->encoders, (void **) &enc, &pos) == SUCCESS;
zend_hash_move_forward_ex(sdl->encoders, &pos)) {
if (strcmp((*enc)->details.type_str, type) == 0) {
return *enc;
}
}
}
return NULL;
}
| DoS Exec Code | 0 | static encodePtr find_encoder_by_type_name(sdlPtr sdl, const char *type)
{
if (sdl && sdl->encoders) {
HashPosition pos;
encodePtr *enc;
for (zend_hash_internal_pointer_reset_ex(sdl->encoders, &pos);
zend_hash_get_current_data_ex(sdl->encoders, (void **) &enc, &pos) == SUCCESS;
zend_hash_move_forward_ex(sdl->encoders, &pos)) {
if (strcmp((*enc)->details.type_str, type) == 0) {
return *enc;
}
}
}
return NULL;
}
| @@ -3649,18 +3649,21 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type TS
Z_OBJCE_PP(tmp) == soap_var_class_entry) {
zval **ztype;
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE ||
+ Z_TYPE_PP(ztype) != IS_LONG) {
soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property");
}
cur_type = Z_LVAL_PP(ztype);
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_stype", sizeof("enc_stype"), (void **)&ztype) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_stype", sizeof("enc_stype"), (void **)&ztype) == SUCCESS &&
+ Z_TYPE_PP(ztype) == IS_STRING) {
cur_stype = Z_STRVAL_PP(ztype);
} else {
cur_stype = NULL;
}
- if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_ns", sizeof("enc_ns"), (void **)&ztype) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_ns", sizeof("enc_ns"), (void **)&ztype) == SUCCESS &&
+ Z_TYPE_PP(ztype) == IS_STRING) {
cur_ns = Z_STRVAL_PP(ztype);
} else {
cur_ns = NULL; | null | null | null |
11,921 | static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, php_stream_context *context, int *use_proxy TSRMLS_DC)
{
php_stream *stream;
zval **proxy_host, **proxy_port, **tmp;
char *host;
char *name;
long namelen;
int port;
int old_error_reporting;
struct timeval tv;
struct timeval *timeout = NULL;
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_host", sizeof("_proxy_host"), (void **) &proxy_host) == SUCCESS &&
Z_TYPE_PP(proxy_host) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_port", sizeof("_proxy_port"), (void **) &proxy_port) == SUCCESS &&
Z_TYPE_PP(proxy_port) == IS_LONG) {
host = Z_STRVAL_PP(proxy_host);
port = Z_LVAL_PP(proxy_port);
*use_proxy = 1;
} else {
host = phpurl->host;
port = phpurl->port;
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_connection_timeout", sizeof("_connection_timeout"), (void **) &tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) > 0) {
tv.tv_sec = Z_LVAL_PP(tmp);
tv.tv_usec = 0;
timeout = &tv;
}
old_error_reporting = EG(error_reporting);
EG(error_reporting) &= ~(E_WARNING|E_NOTICE|E_USER_WARNING|E_USER_NOTICE);
namelen = spprintf(&name, 0, "%s://%s:%d", (use_ssl && !*use_proxy)? "ssl" : "tcp", host, port);
stream = php_stream_xport_create(name, namelen,
REPORT_ERRORS,
STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT,
NULL /*persistent_id*/,
timeout,
context,
NULL, NULL);
efree(name);
/* SSL & proxy */
if (stream && *use_proxy && use_ssl) {
smart_str soap_headers = {0};
char *http_headers;
int http_header_size;
smart_str_append_const(&soap_headers, "CONNECT ");
smart_str_appends(&soap_headers, phpurl->host);
smart_str_appendc(&soap_headers, ':');
smart_str_append_unsigned(&soap_headers, phpurl->port);
smart_str_append_const(&soap_headers, " HTTP/1.1\r\n");
smart_str_append_const(&soap_headers, "Host: ");
smart_str_appends(&soap_headers, phpurl->host);
if (phpurl->port != 80) {
smart_str_appendc(&soap_headers, ':');
smart_str_append_unsigned(&soap_headers, phpurl->port);
}
smart_str_append_const(&soap_headers, "\r\n");
proxy_authentication(this_ptr, &soap_headers TSRMLS_CC);
smart_str_append_const(&soap_headers, "\r\n");
if (php_stream_write(stream, soap_headers.c, soap_headers.len) != soap_headers.len) {
php_stream_close(stream);
stream = NULL;
}
smart_str_free(&soap_headers);
if (stream) {
if (!get_http_headers(stream, &http_headers, &http_header_size TSRMLS_CC) || http_headers == NULL) {
php_stream_close(stream);
stream = NULL;
}
if (http_headers) {
efree(http_headers);
}
}
/* enable SSL transport layer */
if (stream) {
if (php_stream_xport_crypto_setup(stream, STREAM_CRYPTO_METHOD_SSLv23_CLIENT, NULL TSRMLS_CC) < 0 ||
php_stream_xport_crypto_enable(stream, 1 TSRMLS_CC) < 0) {
php_stream_close(stream);
stream = NULL;
}
}
}
EG(error_reporting) = old_error_reporting;
return stream;
}
| DoS Exec Code | 0 | static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, php_stream_context *context, int *use_proxy TSRMLS_DC)
{
php_stream *stream;
zval **proxy_host, **proxy_port, **tmp;
char *host;
char *name;
long namelen;
int port;
int old_error_reporting;
struct timeval tv;
struct timeval *timeout = NULL;
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_host", sizeof("_proxy_host"), (void **) &proxy_host) == SUCCESS &&
Z_TYPE_PP(proxy_host) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_port", sizeof("_proxy_port"), (void **) &proxy_port) == SUCCESS &&
Z_TYPE_PP(proxy_port) == IS_LONG) {
host = Z_STRVAL_PP(proxy_host);
port = Z_LVAL_PP(proxy_port);
*use_proxy = 1;
} else {
host = phpurl->host;
port = phpurl->port;
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_connection_timeout", sizeof("_connection_timeout"), (void **) &tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) > 0) {
tv.tv_sec = Z_LVAL_PP(tmp);
tv.tv_usec = 0;
timeout = &tv;
}
old_error_reporting = EG(error_reporting);
EG(error_reporting) &= ~(E_WARNING|E_NOTICE|E_USER_WARNING|E_USER_NOTICE);
namelen = spprintf(&name, 0, "%s://%s:%d", (use_ssl && !*use_proxy)? "ssl" : "tcp", host, port);
stream = php_stream_xport_create(name, namelen,
REPORT_ERRORS,
STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT,
NULL /*persistent_id*/,
timeout,
context,
NULL, NULL);
efree(name);
/* SSL & proxy */
if (stream && *use_proxy && use_ssl) {
smart_str soap_headers = {0};
char *http_headers;
int http_header_size;
smart_str_append_const(&soap_headers, "CONNECT ");
smart_str_appends(&soap_headers, phpurl->host);
smart_str_appendc(&soap_headers, ':');
smart_str_append_unsigned(&soap_headers, phpurl->port);
smart_str_append_const(&soap_headers, " HTTP/1.1\r\n");
smart_str_append_const(&soap_headers, "Host: ");
smart_str_appends(&soap_headers, phpurl->host);
if (phpurl->port != 80) {
smart_str_appendc(&soap_headers, ':');
smart_str_append_unsigned(&soap_headers, phpurl->port);
}
smart_str_append_const(&soap_headers, "\r\n");
proxy_authentication(this_ptr, &soap_headers TSRMLS_CC);
smart_str_append_const(&soap_headers, "\r\n");
if (php_stream_write(stream, soap_headers.c, soap_headers.len) != soap_headers.len) {
php_stream_close(stream);
stream = NULL;
}
smart_str_free(&soap_headers);
if (stream) {
if (!get_http_headers(stream, &http_headers, &http_header_size TSRMLS_CC) || http_headers == NULL) {
php_stream_close(stream);
stream = NULL;
}
if (http_headers) {
efree(http_headers);
}
}
/* enable SSL transport layer */
if (stream) {
if (php_stream_xport_crypto_setup(stream, STREAM_CRYPTO_METHOD_SSLv23_CLIENT, NULL TSRMLS_CC) < 0 ||
php_stream_xport_crypto_enable(stream, 1 TSRMLS_CC) < 0) {
php_stream_close(stream);
stream = NULL;
}
}
}
EG(error_reporting) = old_error_reporting;
return stream;
}
| @@ -36,14 +36,16 @@ int proxy_authentication(zval* this_ptr, smart_str* soap_headers TSRMLS_DC)
{
zval **login, **password;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_login", sizeof("_proxy_login"), (void **)&login) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_login", sizeof("_proxy_login"), (void **)&login) == SUCCESS &&
+ Z_TYPE_PP(login) == IS_STRING) {
unsigned char* buf;
int len;
smart_str auth = {0};
smart_str_appendl(&auth, Z_STRVAL_PP(login), Z_STRLEN_PP(login));
smart_str_appendc(&auth, ':');
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_password", sizeof("_proxy_password"), (void **)&password) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_password", sizeof("_proxy_password"), (void **)&password) == SUCCESS &&
+ Z_TYPE_PP(password) == IS_STRING) {
smart_str_appendl(&auth, Z_STRVAL_PP(password), Z_STRLEN_PP(password));
}
smart_str_0(&auth);
@@ -64,14 +66,16 @@ int basic_authentication(zval* this_ptr, smart_str* soap_headers TSRMLS_DC)
zval **login, **password;
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_login", sizeof("_login"), (void **)&login) == SUCCESS &&
- !zend_hash_exists(Z_OBJPROP_P(this_ptr), "_digest", sizeof("_digest"))) {
+ Z_TYPE_PP(login) == IS_STRING &&
+ !zend_hash_exists(Z_OBJPROP_P(this_ptr), "_digest", sizeof("_digest"))) {
unsigned char* buf;
int len;
smart_str auth = {0};
smart_str_appendl(&auth, Z_STRVAL_PP(login), Z_STRLEN_PP(login));
smart_str_appendc(&auth, ':');
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_password", sizeof("_password"), (void **)&password) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_password", sizeof("_password"), (void **)&password) == SUCCESS &&
+ Z_TYPE_PP(password) == IS_STRING) {
smart_str_appendl(&auth, Z_STRVAL_PP(password), Z_STRLEN_PP(password));
}
smart_str_0(&auth);
@@ -509,6 +513,7 @@ try_again:
}
if (!http_1_1 ||
(zend_hash_find(Z_OBJPROP_P(this_ptr), "_keep_alive", sizeof("_keep_alive"), (void **)&tmp) == SUCCESS &&
+ (Z_TYPE_PP(tmp) == IS_BOOL || Z_TYPE_PP(tmp) == IS_LONG) &&
Z_LVAL_PP(tmp) == 0)) {
smart_str_append_const(&soap_headers, "\r\n"
"Connection: close\r\n");
@@ -742,7 +747,8 @@ try_again:
}
/* Send cookies along with request */
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zval **data;
char *key;
int i, n;
@@ -785,7 +791,7 @@ try_again:
smart_str_append_const(&soap_headers, "\r\n");
smart_str_0(&soap_headers);
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_TYPE_PP(trace) == IS_BOOL || Z_TYPE_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request_headers", soap_headers.c, soap_headers.len, 1);
}
smart_str_appendl(&soap_headers, request, request_size);
@@ -830,7 +836,7 @@ try_again:
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_TYPE_PP(trace) == IS_BOOL || Z_TYPE_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response_headers", http_headers, http_header_size, 1);
}
@@ -879,7 +885,8 @@ try_again:
char *eqpos, *sempos;
zval **cookies;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
array_init(tmp_cookies); | null | null | null |
11,922 | void http_context_headers(php_stream_context* context,
zend_bool has_authorization,
zend_bool has_proxy_authorization,
zend_bool has_cookies,
smart_str* soap_headers TSRMLS_DC)
{
zval **tmp;
if (context &&
php_stream_context_get_option(context, "http", "header", &tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING && Z_STRLEN_PP(tmp)) {
char *s = Z_STRVAL_PP(tmp);
char *p;
int name_len;
while (*s) {
/* skip leading newlines and spaces */
while (*s == ' ' || *s == '\t' || *s == '\r' || *s == '\n') {
s++;
}
/* extract header name */
p = s;
name_len = -1;
while (*p) {
if (*p == ':') {
if (name_len < 0) name_len = p - s;
break;
} else if (*p == ' ' || *p == '\t') {
if (name_len < 0) name_len = p - s;
} else if (*p == '\r' || *p == '\n') {
break;
}
p++;
}
if (*p == ':') {
/* extract header value */
while (*p && *p != '\r' && *p != '\n') {
p++;
}
/* skip some predefined headers */
if ((name_len != sizeof("host")-1 ||
strncasecmp(s, "host", sizeof("host")-1) != 0) &&
(name_len != sizeof("connection")-1 ||
strncasecmp(s, "connection", sizeof("connection")-1) != 0) &&
(name_len != sizeof("user-agent")-1 ||
strncasecmp(s, "user-agent", sizeof("user-agent")-1) != 0) &&
(name_len != sizeof("content-length")-1 ||
strncasecmp(s, "content-length", sizeof("content-length")-1) != 0) &&
(name_len != sizeof("content-type")-1 ||
strncasecmp(s, "content-type", sizeof("content-type")-1) != 0) &&
(!has_cookies ||
name_len != sizeof("cookie")-1 ||
strncasecmp(s, "cookie", sizeof("cookie")-1) != 0) &&
(!has_authorization ||
name_len != sizeof("authorization")-1 ||
strncasecmp(s, "authorization", sizeof("authorization")-1) != 0) &&
(!has_proxy_authorization ||
name_len != sizeof("proxy-authorization")-1 ||
strncasecmp(s, "proxy-authorization", sizeof("proxy-authorization")-1) != 0)) {
/* add header */
smart_str_appendl(soap_headers, s, p-s);
smart_str_append_const(soap_headers, "\r\n");
}
}
s = (*p) ? (p + 1) : p;
}
}
}
| DoS Exec Code | 0 | void http_context_headers(php_stream_context* context,
zend_bool has_authorization,
zend_bool has_proxy_authorization,
zend_bool has_cookies,
smart_str* soap_headers TSRMLS_DC)
{
zval **tmp;
if (context &&
php_stream_context_get_option(context, "http", "header", &tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING && Z_STRLEN_PP(tmp)) {
char *s = Z_STRVAL_PP(tmp);
char *p;
int name_len;
while (*s) {
/* skip leading newlines and spaces */
while (*s == ' ' || *s == '\t' || *s == '\r' || *s == '\n') {
s++;
}
/* extract header name */
p = s;
name_len = -1;
while (*p) {
if (*p == ':') {
if (name_len < 0) name_len = p - s;
break;
} else if (*p == ' ' || *p == '\t') {
if (name_len < 0) name_len = p - s;
} else if (*p == '\r' || *p == '\n') {
break;
}
p++;
}
if (*p == ':') {
/* extract header value */
while (*p && *p != '\r' && *p != '\n') {
p++;
}
/* skip some predefined headers */
if ((name_len != sizeof("host")-1 ||
strncasecmp(s, "host", sizeof("host")-1) != 0) &&
(name_len != sizeof("connection")-1 ||
strncasecmp(s, "connection", sizeof("connection")-1) != 0) &&
(name_len != sizeof("user-agent")-1 ||
strncasecmp(s, "user-agent", sizeof("user-agent")-1) != 0) &&
(name_len != sizeof("content-length")-1 ||
strncasecmp(s, "content-length", sizeof("content-length")-1) != 0) &&
(name_len != sizeof("content-type")-1 ||
strncasecmp(s, "content-type", sizeof("content-type")-1) != 0) &&
(!has_cookies ||
name_len != sizeof("cookie")-1 ||
strncasecmp(s, "cookie", sizeof("cookie")-1) != 0) &&
(!has_authorization ||
name_len != sizeof("authorization")-1 ||
strncasecmp(s, "authorization", sizeof("authorization")-1) != 0) &&
(!has_proxy_authorization ||
name_len != sizeof("proxy-authorization")-1 ||
strncasecmp(s, "proxy-authorization", sizeof("proxy-authorization")-1) != 0)) {
/* add header */
smart_str_appendl(soap_headers, s, p-s);
smart_str_append_const(soap_headers, "\r\n");
}
}
s = (*p) ? (p + 1) : p;
}
}
}
| @@ -36,14 +36,16 @@ int proxy_authentication(zval* this_ptr, smart_str* soap_headers TSRMLS_DC)
{
zval **login, **password;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_login", sizeof("_proxy_login"), (void **)&login) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_login", sizeof("_proxy_login"), (void **)&login) == SUCCESS &&
+ Z_TYPE_PP(login) == IS_STRING) {
unsigned char* buf;
int len;
smart_str auth = {0};
smart_str_appendl(&auth, Z_STRVAL_PP(login), Z_STRLEN_PP(login));
smart_str_appendc(&auth, ':');
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_password", sizeof("_proxy_password"), (void **)&password) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_password", sizeof("_proxy_password"), (void **)&password) == SUCCESS &&
+ Z_TYPE_PP(password) == IS_STRING) {
smart_str_appendl(&auth, Z_STRVAL_PP(password), Z_STRLEN_PP(password));
}
smart_str_0(&auth);
@@ -64,14 +66,16 @@ int basic_authentication(zval* this_ptr, smart_str* soap_headers TSRMLS_DC)
zval **login, **password;
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_login", sizeof("_login"), (void **)&login) == SUCCESS &&
- !zend_hash_exists(Z_OBJPROP_P(this_ptr), "_digest", sizeof("_digest"))) {
+ Z_TYPE_PP(login) == IS_STRING &&
+ !zend_hash_exists(Z_OBJPROP_P(this_ptr), "_digest", sizeof("_digest"))) {
unsigned char* buf;
int len;
smart_str auth = {0};
smart_str_appendl(&auth, Z_STRVAL_PP(login), Z_STRLEN_PP(login));
smart_str_appendc(&auth, ':');
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_password", sizeof("_password"), (void **)&password) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_password", sizeof("_password"), (void **)&password) == SUCCESS &&
+ Z_TYPE_PP(password) == IS_STRING) {
smart_str_appendl(&auth, Z_STRVAL_PP(password), Z_STRLEN_PP(password));
}
smart_str_0(&auth);
@@ -509,6 +513,7 @@ try_again:
}
if (!http_1_1 ||
(zend_hash_find(Z_OBJPROP_P(this_ptr), "_keep_alive", sizeof("_keep_alive"), (void **)&tmp) == SUCCESS &&
+ (Z_TYPE_PP(tmp) == IS_BOOL || Z_TYPE_PP(tmp) == IS_LONG) &&
Z_LVAL_PP(tmp) == 0)) {
smart_str_append_const(&soap_headers, "\r\n"
"Connection: close\r\n");
@@ -742,7 +747,8 @@ try_again:
}
/* Send cookies along with request */
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zval **data;
char *key;
int i, n;
@@ -785,7 +791,7 @@ try_again:
smart_str_append_const(&soap_headers, "\r\n");
smart_str_0(&soap_headers);
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_TYPE_PP(trace) == IS_BOOL || Z_TYPE_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request_headers", soap_headers.c, soap_headers.len, 1);
}
smart_str_appendl(&soap_headers, request, request_size);
@@ -830,7 +836,7 @@ try_again:
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_TYPE_PP(trace) == IS_BOOL || Z_TYPE_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response_headers", http_headers, http_header_size, 1);
}
@@ -879,7 +885,8 @@ try_again:
char *eqpos, *sempos;
zval **cookies;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
array_init(tmp_cookies); | null | null | null |
11,923 | PHP_FUNCTION(use_soap_error_handler)
{
zend_bool handler = 1;
ZVAL_BOOL(return_value, SOAP_GLOBAL(use_soap_error_handler));
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &handler) == SUCCESS) {
SOAP_GLOBAL(use_soap_error_handler) = handler;
}
}
| DoS Exec Code | 0 | PHP_FUNCTION(use_soap_error_handler)
{
zend_bool handler = 1;
ZVAL_BOOL(return_value, SOAP_GLOBAL(use_soap_error_handler));
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &handler) == SUCCESS) {
SOAP_GLOBAL(use_soap_error_handler) = handler;
}
}
| @@ -2554,7 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -2594,7 +2594,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
ret = FALSE;
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
}
xmlFree(buf);
@@ -2633,13 +2633,13 @@ static void do_soap_call(zval* this_ptr,
SOAP_CLIENT_BEGIN_CODE();
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
- && Z_LVAL_PP(tmp) == SOAP_1_2) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
@@ -2735,7 +2735,7 @@ static void do_soap_call(zval* this_ptr,
zval **uri;
smart_str action = {0};
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3006,7 +3006,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3024,7 +3025,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3042,7 +3044,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3060,7 +3063,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3116,13 +3120,15 @@ PHP_METHOD(SoapClient, __setCookie)
}
if (val == NULL) {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
}
} else {
zval *zcookie;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
@@ -3150,7 +3156,8 @@ PHP_METHOD(SoapClient, __getCookies)
array_init(return_value);
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
}
}
@@ -4237,7 +4244,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
}
} else {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
+ Z_TYPE_PP(zstyle) == IS_LONG) {
style = Z_LVAL_PP(zstyle);
} else {
style = SOAP_RPC;
@@ -4260,7 +4268,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
- Z_LVAL_PP(zuse) == SOAP_LITERAL) {
+ Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
@@ -4390,6 +4398,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
zval **param_data;
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS &&
+ Z_TYPE_PP(param_name) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name); | null | null | null |
11,924 | PHP_FUNCTION(is_soap_fault)
{
zval *fault;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &fault) == SUCCESS &&
Z_TYPE_P(fault) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(fault), soap_fault_class_entry TSRMLS_CC)) {
RETURN_TRUE;
}
RETURN_FALSE
}
| DoS Exec Code | 0 | PHP_FUNCTION(is_soap_fault)
{
zval *fault;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &fault) == SUCCESS &&
Z_TYPE_P(fault) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(fault), soap_fault_class_entry TSRMLS_CC)) {
RETURN_TRUE;
}
RETURN_FALSE
}
| @@ -2554,7 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -2594,7 +2594,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
ret = FALSE;
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
}
xmlFree(buf);
@@ -2633,13 +2633,13 @@ static void do_soap_call(zval* this_ptr,
SOAP_CLIENT_BEGIN_CODE();
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
- && Z_LVAL_PP(tmp) == SOAP_1_2) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
@@ -2735,7 +2735,7 @@ static void do_soap_call(zval* this_ptr,
zval **uri;
smart_str action = {0};
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3006,7 +3006,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3024,7 +3025,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3042,7 +3044,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3060,7 +3063,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3116,13 +3120,15 @@ PHP_METHOD(SoapClient, __setCookie)
}
if (val == NULL) {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
}
} else {
zval *zcookie;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
@@ -3150,7 +3156,8 @@ PHP_METHOD(SoapClient, __getCookies)
array_init(return_value);
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
}
}
@@ -4237,7 +4244,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
}
} else {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
+ Z_TYPE_PP(zstyle) == IS_LONG) {
style = Z_LVAL_PP(zstyle);
} else {
style = SOAP_RPC;
@@ -4260,7 +4268,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
- Z_LVAL_PP(zuse) == SOAP_LITERAL) {
+ Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
@@ -4390,6 +4398,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
zval **param_data;
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS &&
+ Z_TYPE_PP(param_name) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name); | null | null | null |
11,925 | PHP_METHOD(SoapParam, SoapParam)
{
zval *data;
char *name;
int name_length;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs", &data, &name, &name_length) == FAILURE) {
return;
}
if (name_length == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter name");
return;
}
add_property_stringl(this_ptr, "param_name", name, name_length, 1);
add_property_zval(this_ptr, "param_data", data);
}
| DoS Exec Code | 0 | PHP_METHOD(SoapParam, SoapParam)
{
zval *data;
char *name;
int name_length;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs", &data, &name, &name_length) == FAILURE) {
return;
}
if (name_length == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter name");
return;
}
add_property_stringl(this_ptr, "param_name", name, name_length, 1);
add_property_zval(this_ptr, "param_data", data);
}
| @@ -2554,7 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -2594,7 +2594,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
ret = FALSE;
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
}
xmlFree(buf);
@@ -2633,13 +2633,13 @@ static void do_soap_call(zval* this_ptr,
SOAP_CLIENT_BEGIN_CODE();
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
- && Z_LVAL_PP(tmp) == SOAP_1_2) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
@@ -2735,7 +2735,7 @@ static void do_soap_call(zval* this_ptr,
zval **uri;
smart_str action = {0};
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3006,7 +3006,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3024,7 +3025,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3042,7 +3044,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3060,7 +3063,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3116,13 +3120,15 @@ PHP_METHOD(SoapClient, __setCookie)
}
if (val == NULL) {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
}
} else {
zval *zcookie;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
@@ -3150,7 +3156,8 @@ PHP_METHOD(SoapClient, __getCookies)
array_init(return_value);
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
}
}
@@ -4237,7 +4244,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
}
} else {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
+ Z_TYPE_PP(zstyle) == IS_LONG) {
style = Z_LVAL_PP(zstyle);
} else {
style = SOAP_RPC;
@@ -4260,7 +4268,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
- Z_LVAL_PP(zuse) == SOAP_LITERAL) {
+ Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
@@ -4390,6 +4398,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
zval **param_data;
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS &&
+ Z_TYPE_PP(param_name) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name); | null | null | null |
11,926 | PHP_METHOD(SoapHeader, SoapHeader)
{
zval *data = NULL, *actor = NULL;
char *name, *ns;
int name_len, ns_len;
zend_bool must_understand = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|zbz", &ns, &ns_len, &name, &name_len, &data, &must_understand, &actor) == FAILURE) {
return;
}
if (ns_len == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid namespace");
return;
}
if (name_len == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid header name");
return;
}
add_property_stringl(this_ptr, "namespace", ns, ns_len, 1);
add_property_stringl(this_ptr, "name", name, name_len, 1);
if (data) {
add_property_zval(this_ptr, "data", data);
}
add_property_bool(this_ptr, "mustUnderstand", must_understand);
if (actor == NULL) {
} else if (Z_TYPE_P(actor) == IS_LONG &&
(Z_LVAL_P(actor) == SOAP_ACTOR_NEXT ||
Z_LVAL_P(actor) == SOAP_ACTOR_NONE ||
Z_LVAL_P(actor) == SOAP_ACTOR_UNLIMATERECEIVER)) {
add_property_long(this_ptr, "actor", Z_LVAL_P(actor));
} else if (Z_TYPE_P(actor) == IS_STRING && Z_STRLEN_P(actor) > 0) {
add_property_stringl(this_ptr, "actor", Z_STRVAL_P(actor), Z_STRLEN_P(actor), 1);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid actor");
}
}
| DoS Exec Code | 0 | PHP_METHOD(SoapHeader, SoapHeader)
{
zval *data = NULL, *actor = NULL;
char *name, *ns;
int name_len, ns_len;
zend_bool must_understand = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|zbz", &ns, &ns_len, &name, &name_len, &data, &must_understand, &actor) == FAILURE) {
return;
}
if (ns_len == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid namespace");
return;
}
if (name_len == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid header name");
return;
}
add_property_stringl(this_ptr, "namespace", ns, ns_len, 1);
add_property_stringl(this_ptr, "name", name, name_len, 1);
if (data) {
add_property_zval(this_ptr, "data", data);
}
add_property_bool(this_ptr, "mustUnderstand", must_understand);
if (actor == NULL) {
} else if (Z_TYPE_P(actor) == IS_LONG &&
(Z_LVAL_P(actor) == SOAP_ACTOR_NEXT ||
Z_LVAL_P(actor) == SOAP_ACTOR_NONE ||
Z_LVAL_P(actor) == SOAP_ACTOR_UNLIMATERECEIVER)) {
add_property_long(this_ptr, "actor", Z_LVAL_P(actor));
} else if (Z_TYPE_P(actor) == IS_STRING && Z_STRLEN_P(actor) > 0) {
add_property_stringl(this_ptr, "actor", Z_STRVAL_P(actor), Z_STRLEN_P(actor), 1);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid actor");
}
}
| @@ -2554,7 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -2594,7 +2594,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
ret = FALSE;
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
}
xmlFree(buf);
@@ -2633,13 +2633,13 @@ static void do_soap_call(zval* this_ptr,
SOAP_CLIENT_BEGIN_CODE();
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
- && Z_LVAL_PP(tmp) == SOAP_1_2) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
@@ -2735,7 +2735,7 @@ static void do_soap_call(zval* this_ptr,
zval **uri;
smart_str action = {0};
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3006,7 +3006,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3024,7 +3025,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3042,7 +3044,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3060,7 +3063,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3116,13 +3120,15 @@ PHP_METHOD(SoapClient, __setCookie)
}
if (val == NULL) {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
}
} else {
zval *zcookie;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
@@ -3150,7 +3156,8 @@ PHP_METHOD(SoapClient, __getCookies)
array_init(return_value);
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
}
}
@@ -4237,7 +4244,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
}
} else {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
+ Z_TYPE_PP(zstyle) == IS_LONG) {
style = Z_LVAL_PP(zstyle);
} else {
style = SOAP_RPC;
@@ -4260,7 +4268,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
- Z_LVAL_PP(zuse) == SOAP_LITERAL) {
+ Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
@@ -4390,6 +4398,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
zval **param_data;
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS &&
+ Z_TYPE_PP(param_name) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name); | null | null | null |
11,927 | PHP_METHOD(SoapFault, SoapFault)
{
char *fault_string = NULL, *fault_code = NULL, *fault_actor = NULL, *name = NULL, *fault_code_ns = NULL;
int fault_string_len, fault_actor_len = 0, name_len = 0, fault_code_len = 0;
zval *code = NULL, *details = NULL, *headerfault = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs|s!z!s!z",
&code,
&fault_string, &fault_string_len,
&fault_actor, &fault_actor_len,
&details, &name, &name_len, &headerfault) == FAILURE) {
return;
}
if (Z_TYPE_P(code) == IS_NULL) {
} else if (Z_TYPE_P(code) == IS_STRING) {
fault_code = Z_STRVAL_P(code);
fault_code_len = Z_STRLEN_P(code);
} else if (Z_TYPE_P(code) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL_P(code)) == 2) {
zval **t_ns, **t_code;
zend_hash_internal_pointer_reset(Z_ARRVAL_P(code));
zend_hash_get_current_data(Z_ARRVAL_P(code), (void**)&t_ns);
zend_hash_move_forward(Z_ARRVAL_P(code));
zend_hash_get_current_data(Z_ARRVAL_P(code), (void**)&t_code);
if (Z_TYPE_PP(t_ns) == IS_STRING && Z_TYPE_PP(t_code) == IS_STRING) {
fault_code_ns = Z_STRVAL_PP(t_ns);
fault_code = Z_STRVAL_PP(t_code);
fault_code_len = Z_STRLEN_PP(t_code);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid fault code");
return;
}
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid fault code");
return;
}
if (fault_code != NULL && fault_code_len == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid fault code");
return;
}
if (name != NULL && name_len == 0) {
name = NULL;
}
set_soap_fault(this_ptr, fault_code_ns, fault_code, fault_string, fault_actor, details, name TSRMLS_CC);
if (headerfault != NULL) {
add_property_zval(this_ptr, "headerfault", headerfault);
}
}
| DoS Exec Code | 0 | PHP_METHOD(SoapFault, SoapFault)
{
char *fault_string = NULL, *fault_code = NULL, *fault_actor = NULL, *name = NULL, *fault_code_ns = NULL;
int fault_string_len, fault_actor_len = 0, name_len = 0, fault_code_len = 0;
zval *code = NULL, *details = NULL, *headerfault = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs|s!z!s!z",
&code,
&fault_string, &fault_string_len,
&fault_actor, &fault_actor_len,
&details, &name, &name_len, &headerfault) == FAILURE) {
return;
}
if (Z_TYPE_P(code) == IS_NULL) {
} else if (Z_TYPE_P(code) == IS_STRING) {
fault_code = Z_STRVAL_P(code);
fault_code_len = Z_STRLEN_P(code);
} else if (Z_TYPE_P(code) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL_P(code)) == 2) {
zval **t_ns, **t_code;
zend_hash_internal_pointer_reset(Z_ARRVAL_P(code));
zend_hash_get_current_data(Z_ARRVAL_P(code), (void**)&t_ns);
zend_hash_move_forward(Z_ARRVAL_P(code));
zend_hash_get_current_data(Z_ARRVAL_P(code), (void**)&t_code);
if (Z_TYPE_PP(t_ns) == IS_STRING && Z_TYPE_PP(t_code) == IS_STRING) {
fault_code_ns = Z_STRVAL_PP(t_ns);
fault_code = Z_STRVAL_PP(t_code);
fault_code_len = Z_STRLEN_PP(t_code);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid fault code");
return;
}
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid fault code");
return;
}
if (fault_code != NULL && fault_code_len == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid fault code");
return;
}
if (name != NULL && name_len == 0) {
name = NULL;
}
set_soap_fault(this_ptr, fault_code_ns, fault_code, fault_string, fault_actor, details, name TSRMLS_CC);
if (headerfault != NULL) {
add_property_zval(this_ptr, "headerfault", headerfault);
}
}
| @@ -2554,7 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -2594,7 +2594,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
ret = FALSE;
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
}
xmlFree(buf);
@@ -2633,13 +2633,13 @@ static void do_soap_call(zval* this_ptr,
SOAP_CLIENT_BEGIN_CODE();
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
- && Z_LVAL_PP(tmp) == SOAP_1_2) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
@@ -2735,7 +2735,7 @@ static void do_soap_call(zval* this_ptr,
zval **uri;
smart_str action = {0};
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3006,7 +3006,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3024,7 +3025,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3042,7 +3044,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3060,7 +3063,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3116,13 +3120,15 @@ PHP_METHOD(SoapClient, __setCookie)
}
if (val == NULL) {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
}
} else {
zval *zcookie;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
@@ -3150,7 +3156,8 @@ PHP_METHOD(SoapClient, __getCookies)
array_init(return_value);
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
}
}
@@ -4237,7 +4244,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
}
} else {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
+ Z_TYPE_PP(zstyle) == IS_LONG) {
style = Z_LVAL_PP(zstyle);
} else {
style = SOAP_RPC;
@@ -4260,7 +4268,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
- Z_LVAL_PP(zuse) == SOAP_LITERAL) {
+ Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
@@ -4390,6 +4398,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
zval **param_data;
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS &&
+ Z_TYPE_PP(param_name) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name); | null | null | null |
11,928 | PHP_METHOD(SoapServer, SoapServer)
{
soapServicePtr service;
zval *wsdl = NULL, *options = NULL;
int ret;
int version = SOAP_1_1;
long cache_wsdl;
HashTable *typemap_ht = NULL;
SOAP_SERVER_BEGIN_CODE();
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "z|a", &wsdl, &options) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters");
}
if (Z_TYPE_P(wsdl) != IS_STRING && Z_TYPE_P(wsdl) != IS_NULL) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters");
}
service = emalloc(sizeof(soapService));
memset(service, 0, sizeof(soapService));
service->send_errors = 1;
cache_wsdl = SOAP_GLOBAL(cache_enabled) ? SOAP_GLOBAL(cache_mode) : 0;
if (options != NULL) {
HashTable *ht = Z_ARRVAL_P(options);
zval **tmp;
if (zend_hash_find(ht, "soap_version", sizeof("soap_version"), (void**)&tmp) == SUCCESS) {
if (Z_TYPE_PP(tmp) == IS_LONG &&
(Z_LVAL_PP(tmp) == SOAP_1_1 || Z_LVAL_PP(tmp) == SOAP_1_2)) {
version = Z_LVAL_PP(tmp);
} else {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "'soap_version' option must be SOAP_1_1 or SOAP_1_2");
}
}
if (zend_hash_find(ht, "uri", sizeof("uri"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING) {
service->uri = estrndup(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
} else if (Z_TYPE_P(wsdl) == IS_NULL) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "'uri' option is required in nonWSDL mode");
}
if (zend_hash_find(ht, "actor", sizeof("actor"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING) {
service->actor = estrndup(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
}
if (zend_hash_find(ht, "encoding", sizeof("encoding"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING) {
xmlCharEncodingHandlerPtr encoding;
encoding = xmlFindCharEncodingHandler(Z_STRVAL_PP(tmp));
if (encoding == NULL) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid 'encoding' option - '%s'", Z_STRVAL_PP(tmp));
} else {
service->encoding = encoding;
}
}
if (zend_hash_find(ht, "classmap", sizeof("classmap"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_ARRAY) {
zval *ztmp;
ALLOC_HASHTABLE(service->class_map);
zend_hash_init(service->class_map, zend_hash_num_elements((*tmp)->value.ht), NULL, ZVAL_PTR_DTOR, 0);
zend_hash_copy(service->class_map, (*tmp)->value.ht, (copy_ctor_func_t) zval_add_ref, (void *) &ztmp, sizeof(zval *));
}
if (zend_hash_find(ht, "typemap", sizeof("typemap"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_ARRAY &&
zend_hash_num_elements(Z_ARRVAL_PP(tmp)) > 0) {
typemap_ht = Z_ARRVAL_PP(tmp);
}
if (zend_hash_find(ht, "features", sizeof("features"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_LONG) {
service->features = Z_LVAL_PP(tmp);
}
if (zend_hash_find(ht, "cache_wsdl", sizeof("cache_wsdl"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_LONG) {
cache_wsdl = Z_LVAL_PP(tmp);
}
if (zend_hash_find(ht, "send_errors", sizeof("send_errors"), (void**)&tmp) == SUCCESS &&
(Z_TYPE_PP(tmp) == IS_BOOL || Z_TYPE_PP(tmp) == IS_LONG)) {
service->send_errors = Z_LVAL_PP(tmp);
}
} else if (Z_TYPE_P(wsdl) == IS_NULL) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "'uri' option is required in nonWSDL mode");
}
service->version = version;
service->type = SOAP_FUNCTIONS;
service->soap_functions.functions_all = FALSE;
service->soap_functions.ft = emalloc(sizeof(HashTable));
zend_hash_init(service->soap_functions.ft, 0, NULL, ZVAL_PTR_DTOR, 0);
if (Z_TYPE_P(wsdl) != IS_NULL) {
service->sdl = get_sdl(this_ptr, Z_STRVAL_P(wsdl), cache_wsdl TSRMLS_CC);
if (service->uri == NULL) {
if (service->sdl->target_ns) {
service->uri = estrdup(service->sdl->target_ns);
} else {
/*FIXME*/
service->uri = estrdup("http://unknown-uri/");
}
}
}
if (typemap_ht) {
service->typemap = soap_create_typemap(service->sdl, typemap_ht TSRMLS_CC);
}
ret = zend_list_insert(service, le_service TSRMLS_CC);
add_property_resource(this_ptr, "service", ret);
SOAP_SERVER_END_CODE();
}
| DoS Exec Code | 0 | PHP_METHOD(SoapServer, SoapServer)
{
soapServicePtr service;
zval *wsdl = NULL, *options = NULL;
int ret;
int version = SOAP_1_1;
long cache_wsdl;
HashTable *typemap_ht = NULL;
SOAP_SERVER_BEGIN_CODE();
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "z|a", &wsdl, &options) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters");
}
if (Z_TYPE_P(wsdl) != IS_STRING && Z_TYPE_P(wsdl) != IS_NULL) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters");
}
service = emalloc(sizeof(soapService));
memset(service, 0, sizeof(soapService));
service->send_errors = 1;
cache_wsdl = SOAP_GLOBAL(cache_enabled) ? SOAP_GLOBAL(cache_mode) : 0;
if (options != NULL) {
HashTable *ht = Z_ARRVAL_P(options);
zval **tmp;
if (zend_hash_find(ht, "soap_version", sizeof("soap_version"), (void**)&tmp) == SUCCESS) {
if (Z_TYPE_PP(tmp) == IS_LONG &&
(Z_LVAL_PP(tmp) == SOAP_1_1 || Z_LVAL_PP(tmp) == SOAP_1_2)) {
version = Z_LVAL_PP(tmp);
} else {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "'soap_version' option must be SOAP_1_1 or SOAP_1_2");
}
}
if (zend_hash_find(ht, "uri", sizeof("uri"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING) {
service->uri = estrndup(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
} else if (Z_TYPE_P(wsdl) == IS_NULL) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "'uri' option is required in nonWSDL mode");
}
if (zend_hash_find(ht, "actor", sizeof("actor"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING) {
service->actor = estrndup(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
}
if (zend_hash_find(ht, "encoding", sizeof("encoding"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING) {
xmlCharEncodingHandlerPtr encoding;
encoding = xmlFindCharEncodingHandler(Z_STRVAL_PP(tmp));
if (encoding == NULL) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid 'encoding' option - '%s'", Z_STRVAL_PP(tmp));
} else {
service->encoding = encoding;
}
}
if (zend_hash_find(ht, "classmap", sizeof("classmap"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_ARRAY) {
zval *ztmp;
ALLOC_HASHTABLE(service->class_map);
zend_hash_init(service->class_map, zend_hash_num_elements((*tmp)->value.ht), NULL, ZVAL_PTR_DTOR, 0);
zend_hash_copy(service->class_map, (*tmp)->value.ht, (copy_ctor_func_t) zval_add_ref, (void *) &ztmp, sizeof(zval *));
}
if (zend_hash_find(ht, "typemap", sizeof("typemap"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_ARRAY &&
zend_hash_num_elements(Z_ARRVAL_PP(tmp)) > 0) {
typemap_ht = Z_ARRVAL_PP(tmp);
}
if (zend_hash_find(ht, "features", sizeof("features"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_LONG) {
service->features = Z_LVAL_PP(tmp);
}
if (zend_hash_find(ht, "cache_wsdl", sizeof("cache_wsdl"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_LONG) {
cache_wsdl = Z_LVAL_PP(tmp);
}
if (zend_hash_find(ht, "send_errors", sizeof("send_errors"), (void**)&tmp) == SUCCESS &&
(Z_TYPE_PP(tmp) == IS_BOOL || Z_TYPE_PP(tmp) == IS_LONG)) {
service->send_errors = Z_LVAL_PP(tmp);
}
} else if (Z_TYPE_P(wsdl) == IS_NULL) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "'uri' option is required in nonWSDL mode");
}
service->version = version;
service->type = SOAP_FUNCTIONS;
service->soap_functions.functions_all = FALSE;
service->soap_functions.ft = emalloc(sizeof(HashTable));
zend_hash_init(service->soap_functions.ft, 0, NULL, ZVAL_PTR_DTOR, 0);
if (Z_TYPE_P(wsdl) != IS_NULL) {
service->sdl = get_sdl(this_ptr, Z_STRVAL_P(wsdl), cache_wsdl TSRMLS_CC);
if (service->uri == NULL) {
if (service->sdl->target_ns) {
service->uri = estrdup(service->sdl->target_ns);
} else {
/*FIXME*/
service->uri = estrdup("http://unknown-uri/");
}
}
}
if (typemap_ht) {
service->typemap = soap_create_typemap(service->sdl, typemap_ht TSRMLS_CC);
}
ret = zend_list_insert(service, le_service TSRMLS_CC);
add_property_resource(this_ptr, "service", ret);
SOAP_SERVER_END_CODE();
}
| @@ -2554,7 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -2594,7 +2594,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
ret = FALSE;
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
}
xmlFree(buf);
@@ -2633,13 +2633,13 @@ static void do_soap_call(zval* this_ptr,
SOAP_CLIENT_BEGIN_CODE();
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
- && Z_LVAL_PP(tmp) == SOAP_1_2) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
@@ -2735,7 +2735,7 @@ static void do_soap_call(zval* this_ptr,
zval **uri;
smart_str action = {0};
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3006,7 +3006,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3024,7 +3025,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3042,7 +3044,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3060,7 +3063,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3116,13 +3120,15 @@ PHP_METHOD(SoapClient, __setCookie)
}
if (val == NULL) {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
}
} else {
zval *zcookie;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
@@ -3150,7 +3156,8 @@ PHP_METHOD(SoapClient, __getCookies)
array_init(return_value);
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
}
}
@@ -4237,7 +4244,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
}
} else {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
+ Z_TYPE_PP(zstyle) == IS_LONG) {
style = Z_LVAL_PP(zstyle);
} else {
style = SOAP_RPC;
@@ -4260,7 +4268,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
- Z_LVAL_PP(zuse) == SOAP_LITERAL) {
+ Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
@@ -4390,6 +4398,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
zval **param_data;
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS &&
+ Z_TYPE_PP(param_name) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name); | null | null | null |
11,929 | PHP_METHOD(SoapServer, setPersistence)
{
soapServicePtr service;
long value;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) != FAILURE) {
if (service->type == SOAP_CLASS) {
if (value == SOAP_PERSISTENCE_SESSION ||
value == SOAP_PERSISTENCE_REQUEST) {
service->soap_class.persistance = value;
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to set persistence with bogus value (%ld)", value);
return;
}
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to set persistence when you are using you SOAP SERVER in function mode, no persistence needed");
return;
}
}
SOAP_SERVER_END_CODE();
}
| DoS Exec Code | 0 | PHP_METHOD(SoapServer, setPersistence)
{
soapServicePtr service;
long value;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) != FAILURE) {
if (service->type == SOAP_CLASS) {
if (value == SOAP_PERSISTENCE_SESSION ||
value == SOAP_PERSISTENCE_REQUEST) {
service->soap_class.persistance = value;
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to set persistence with bogus value (%ld)", value);
return;
}
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to set persistence when you are using you SOAP SERVER in function mode, no persistence needed");
return;
}
}
SOAP_SERVER_END_CODE();
}
| @@ -2554,7 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -2594,7 +2594,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
ret = FALSE;
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
}
xmlFree(buf);
@@ -2633,13 +2633,13 @@ static void do_soap_call(zval* this_ptr,
SOAP_CLIENT_BEGIN_CODE();
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
- && Z_LVAL_PP(tmp) == SOAP_1_2) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
@@ -2735,7 +2735,7 @@ static void do_soap_call(zval* this_ptr,
zval **uri;
smart_str action = {0};
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3006,7 +3006,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3024,7 +3025,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3042,7 +3044,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3060,7 +3063,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3116,13 +3120,15 @@ PHP_METHOD(SoapClient, __setCookie)
}
if (val == NULL) {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
}
} else {
zval *zcookie;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
@@ -3150,7 +3156,8 @@ PHP_METHOD(SoapClient, __getCookies)
array_init(return_value);
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
}
}
@@ -4237,7 +4244,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
}
} else {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
+ Z_TYPE_PP(zstyle) == IS_LONG) {
style = Z_LVAL_PP(zstyle);
} else {
style = SOAP_RPC;
@@ -4260,7 +4268,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
- Z_LVAL_PP(zuse) == SOAP_LITERAL) {
+ Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
@@ -4390,6 +4398,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
zval **param_data;
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS &&
+ Z_TYPE_PP(param_name) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name); | null | null | null |
11,930 | PHP_METHOD(SoapServer, setClass)
{
soapServicePtr service;
char *classname;
zend_class_entry **ce;
int classname_len, found, num_args = 0;
zval ***argv = NULL;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s*", &classname, &classname_len, &argv, &num_args) == FAILURE) {
return;
}
found = zend_lookup_class(classname, classname_len, &ce TSRMLS_CC);
if (found != FAILURE) {
service->type = SOAP_CLASS;
service->soap_class.ce = *ce;
service->soap_class.persistance = SOAP_PERSISTENCE_REQUEST;
service->soap_class.argc = num_args;
if (service->soap_class.argc > 0) {
int i;
service->soap_class.argv = safe_emalloc(sizeof(zval), service->soap_class.argc, 0);
for (i = 0;i < service->soap_class.argc;i++) {
service->soap_class.argv[i] = *(argv[i]);
zval_add_ref(&service->soap_class.argv[i]);
}
}
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to set a non existent class (%s)", classname);
return;
}
if (argv) {
efree(argv);
}
SOAP_SERVER_END_CODE();
}
| DoS Exec Code | 0 | PHP_METHOD(SoapServer, setClass)
{
soapServicePtr service;
char *classname;
zend_class_entry **ce;
int classname_len, found, num_args = 0;
zval ***argv = NULL;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s*", &classname, &classname_len, &argv, &num_args) == FAILURE) {
return;
}
found = zend_lookup_class(classname, classname_len, &ce TSRMLS_CC);
if (found != FAILURE) {
service->type = SOAP_CLASS;
service->soap_class.ce = *ce;
service->soap_class.persistance = SOAP_PERSISTENCE_REQUEST;
service->soap_class.argc = num_args;
if (service->soap_class.argc > 0) {
int i;
service->soap_class.argv = safe_emalloc(sizeof(zval), service->soap_class.argc, 0);
for (i = 0;i < service->soap_class.argc;i++) {
service->soap_class.argv[i] = *(argv[i]);
zval_add_ref(&service->soap_class.argv[i]);
}
}
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to set a non existent class (%s)", classname);
return;
}
if (argv) {
efree(argv);
}
SOAP_SERVER_END_CODE();
}
| @@ -2554,7 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -2594,7 +2594,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
ret = FALSE;
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
}
xmlFree(buf);
@@ -2633,13 +2633,13 @@ static void do_soap_call(zval* this_ptr,
SOAP_CLIENT_BEGIN_CODE();
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
- && Z_LVAL_PP(tmp) == SOAP_1_2) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
@@ -2735,7 +2735,7 @@ static void do_soap_call(zval* this_ptr,
zval **uri;
smart_str action = {0};
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3006,7 +3006,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3024,7 +3025,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3042,7 +3044,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3060,7 +3063,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3116,13 +3120,15 @@ PHP_METHOD(SoapClient, __setCookie)
}
if (val == NULL) {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
}
} else {
zval *zcookie;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
@@ -3150,7 +3156,8 @@ PHP_METHOD(SoapClient, __getCookies)
array_init(return_value);
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
}
}
@@ -4237,7 +4244,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
}
} else {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
+ Z_TYPE_PP(zstyle) == IS_LONG) {
style = Z_LVAL_PP(zstyle);
} else {
style = SOAP_RPC;
@@ -4260,7 +4268,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
- Z_LVAL_PP(zuse) == SOAP_LITERAL) {
+ Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
@@ -4390,6 +4398,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
zval **param_data;
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS &&
+ Z_TYPE_PP(param_name) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name); | null | null | null |
11,931 | PHP_METHOD(SoapServer, setObject)
{
soapServicePtr service;
zval *obj;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
return;
}
service->type = SOAP_OBJECT;
MAKE_STD_ZVAL(service->soap_object);
MAKE_COPY_ZVAL(&obj, service->soap_object);
SOAP_SERVER_END_CODE();
}
| DoS Exec Code | 0 | PHP_METHOD(SoapServer, setObject)
{
soapServicePtr service;
zval *obj;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
return;
}
service->type = SOAP_OBJECT;
MAKE_STD_ZVAL(service->soap_object);
MAKE_COPY_ZVAL(&obj, service->soap_object);
SOAP_SERVER_END_CODE();
}
| @@ -2554,7 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -2594,7 +2594,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
ret = FALSE;
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
}
xmlFree(buf);
@@ -2633,13 +2633,13 @@ static void do_soap_call(zval* this_ptr,
SOAP_CLIENT_BEGIN_CODE();
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
- && Z_LVAL_PP(tmp) == SOAP_1_2) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
@@ -2735,7 +2735,7 @@ static void do_soap_call(zval* this_ptr,
zval **uri;
smart_str action = {0};
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3006,7 +3006,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3024,7 +3025,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3042,7 +3044,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3060,7 +3063,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3116,13 +3120,15 @@ PHP_METHOD(SoapClient, __setCookie)
}
if (val == NULL) {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
}
} else {
zval *zcookie;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
@@ -3150,7 +3156,8 @@ PHP_METHOD(SoapClient, __getCookies)
array_init(return_value);
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
}
}
@@ -4237,7 +4244,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
}
} else {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
+ Z_TYPE_PP(zstyle) == IS_LONG) {
style = Z_LVAL_PP(zstyle);
} else {
style = SOAP_RPC;
@@ -4260,7 +4268,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
- Z_LVAL_PP(zuse) == SOAP_LITERAL) {
+ Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
@@ -4390,6 +4398,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
zval **param_data;
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS &&
+ Z_TYPE_PP(param_name) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name); | null | null | null |
11,932 | PHP_METHOD(SoapServer, getFunctions)
{
soapServicePtr service;
HashTable *ft = NULL;
SOAP_SERVER_BEGIN_CODE();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
FETCH_THIS_SERVICE(service);
array_init(return_value);
if (service->type == SOAP_OBJECT) {
ft = &(Z_OBJCE_P(service->soap_object)->function_table);
} else if (service->type == SOAP_CLASS) {
ft = &service->soap_class.ce->function_table;
} else if (service->soap_functions.functions_all == TRUE) {
ft = EG(function_table);
} else if (service->soap_functions.ft != NULL) {
zval **name;
HashPosition pos;
zend_hash_internal_pointer_reset_ex(service->soap_functions.ft, &pos);
while (zend_hash_get_current_data_ex(service->soap_functions.ft, (void **)&name, &pos) != FAILURE) {
add_next_index_string(return_value, Z_STRVAL_PP(name), 1);
zend_hash_move_forward_ex(service->soap_functions.ft, &pos);
}
}
if (ft != NULL) {
zend_function *f;
HashPosition pos;
zend_hash_internal_pointer_reset_ex(ft, &pos);
while (zend_hash_get_current_data_ex(ft, (void **)&f, &pos) != FAILURE) {
if ((service->type != SOAP_OBJECT && service->type != SOAP_CLASS) || (f->common.fn_flags & ZEND_ACC_PUBLIC)) {
add_next_index_string(return_value, f->common.function_name, 1);
}
zend_hash_move_forward_ex(ft, &pos);
}
}
SOAP_SERVER_END_CODE();
}
| DoS Exec Code | 0 | PHP_METHOD(SoapServer, getFunctions)
{
soapServicePtr service;
HashTable *ft = NULL;
SOAP_SERVER_BEGIN_CODE();
if (zend_parse_parameters_none() == FAILURE) {
return;
}
FETCH_THIS_SERVICE(service);
array_init(return_value);
if (service->type == SOAP_OBJECT) {
ft = &(Z_OBJCE_P(service->soap_object)->function_table);
} else if (service->type == SOAP_CLASS) {
ft = &service->soap_class.ce->function_table;
} else if (service->soap_functions.functions_all == TRUE) {
ft = EG(function_table);
} else if (service->soap_functions.ft != NULL) {
zval **name;
HashPosition pos;
zend_hash_internal_pointer_reset_ex(service->soap_functions.ft, &pos);
while (zend_hash_get_current_data_ex(service->soap_functions.ft, (void **)&name, &pos) != FAILURE) {
add_next_index_string(return_value, Z_STRVAL_PP(name), 1);
zend_hash_move_forward_ex(service->soap_functions.ft, &pos);
}
}
if (ft != NULL) {
zend_function *f;
HashPosition pos;
zend_hash_internal_pointer_reset_ex(ft, &pos);
while (zend_hash_get_current_data_ex(ft, (void **)&f, &pos) != FAILURE) {
if ((service->type != SOAP_OBJECT && service->type != SOAP_CLASS) || (f->common.fn_flags & ZEND_ACC_PUBLIC)) {
add_next_index_string(return_value, f->common.function_name, 1);
}
zend_hash_move_forward_ex(ft, &pos);
}
}
SOAP_SERVER_END_CODE();
}
| @@ -2554,7 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -2594,7 +2594,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
ret = FALSE;
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
}
xmlFree(buf);
@@ -2633,13 +2633,13 @@ static void do_soap_call(zval* this_ptr,
SOAP_CLIENT_BEGIN_CODE();
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
- && Z_LVAL_PP(tmp) == SOAP_1_2) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
@@ -2735,7 +2735,7 @@ static void do_soap_call(zval* this_ptr,
zval **uri;
smart_str action = {0};
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3006,7 +3006,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3024,7 +3025,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3042,7 +3044,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3060,7 +3063,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3116,13 +3120,15 @@ PHP_METHOD(SoapClient, __setCookie)
}
if (val == NULL) {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
}
} else {
zval *zcookie;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
@@ -3150,7 +3156,8 @@ PHP_METHOD(SoapClient, __getCookies)
array_init(return_value);
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
}
}
@@ -4237,7 +4244,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
}
} else {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
+ Z_TYPE_PP(zstyle) == IS_LONG) {
style = Z_LVAL_PP(zstyle);
} else {
style = SOAP_RPC;
@@ -4260,7 +4268,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
- Z_LVAL_PP(zuse) == SOAP_LITERAL) {
+ Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
@@ -4390,6 +4398,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
zval **param_data;
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS &&
+ Z_TYPE_PP(param_name) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name); | null | null | null |
11,933 | PHP_METHOD(SoapServer, addFunction)
{
soapServicePtr service;
zval *function_name, *function_copy;
HashPosition pos;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &function_name) == FAILURE) {
return;
}
/* TODO: could use zend_is_callable here */
if (function_name->type == IS_ARRAY) {
if (service->type == SOAP_FUNCTIONS) {
zval **tmp_function, *function_copy;
if (service->soap_functions.ft == NULL) {
service->soap_functions.functions_all = FALSE;
service->soap_functions.ft = emalloc(sizeof(HashTable));
zend_hash_init(service->soap_functions.ft, zend_hash_num_elements(Z_ARRVAL_P(function_name)), NULL, ZVAL_PTR_DTOR, 0);
}
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(function_name), &pos);
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(function_name), (void **)&tmp_function, &pos) != FAILURE) {
char *key;
int key_len;
zend_function *f;
if (Z_TYPE_PP(tmp_function) != IS_STRING) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to add a function that isn't a string");
return;
}
key_len = Z_STRLEN_PP(tmp_function);
key = emalloc(key_len + 1);
zend_str_tolower_copy(key, Z_STRVAL_PP(tmp_function), key_len);
if (zend_hash_find(EG(function_table), key, key_len+1, (void**)&f) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to add a non existent function '%s'", Z_STRVAL_PP(tmp_function));
return;
}
MAKE_STD_ZVAL(function_copy);
ZVAL_STRING(function_copy, f->common.function_name, 1);
zend_hash_update(service->soap_functions.ft, key, key_len+1, &function_copy, sizeof(zval *), NULL);
efree(key);
zend_hash_move_forward_ex(Z_ARRVAL_P(function_name), &pos);
}
}
} else if (function_name->type == IS_STRING) {
char *key;
int key_len;
zend_function *f;
key_len = Z_STRLEN_P(function_name);
key = emalloc(key_len + 1);
zend_str_tolower_copy(key, Z_STRVAL_P(function_name), key_len);
if (zend_hash_find(EG(function_table), key, key_len+1, (void**)&f) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to add a non existent function '%s'", Z_STRVAL_P(function_name));
return;
}
if (service->soap_functions.ft == NULL) {
service->soap_functions.functions_all = FALSE;
service->soap_functions.ft = emalloc(sizeof(HashTable));
zend_hash_init(service->soap_functions.ft, 0, NULL, ZVAL_PTR_DTOR, 0);
}
MAKE_STD_ZVAL(function_copy);
ZVAL_STRING(function_copy, f->common.function_name, 1);
zend_hash_update(service->soap_functions.ft, key, key_len+1, &function_copy, sizeof(zval *), NULL);
efree(key);
} else if (function_name->type == IS_LONG) {
if (Z_LVAL_P(function_name) == SOAP_FUNCTIONS_ALL) {
if (service->soap_functions.ft != NULL) {
zend_hash_destroy(service->soap_functions.ft);
efree(service->soap_functions.ft);
service->soap_functions.ft = NULL;
}
service->soap_functions.functions_all = TRUE;
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value passed");
return;
}
}
SOAP_SERVER_END_CODE();
}
| DoS Exec Code | 0 | PHP_METHOD(SoapServer, addFunction)
{
soapServicePtr service;
zval *function_name, *function_copy;
HashPosition pos;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &function_name) == FAILURE) {
return;
}
/* TODO: could use zend_is_callable here */
if (function_name->type == IS_ARRAY) {
if (service->type == SOAP_FUNCTIONS) {
zval **tmp_function, *function_copy;
if (service->soap_functions.ft == NULL) {
service->soap_functions.functions_all = FALSE;
service->soap_functions.ft = emalloc(sizeof(HashTable));
zend_hash_init(service->soap_functions.ft, zend_hash_num_elements(Z_ARRVAL_P(function_name)), NULL, ZVAL_PTR_DTOR, 0);
}
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(function_name), &pos);
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(function_name), (void **)&tmp_function, &pos) != FAILURE) {
char *key;
int key_len;
zend_function *f;
if (Z_TYPE_PP(tmp_function) != IS_STRING) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to add a function that isn't a string");
return;
}
key_len = Z_STRLEN_PP(tmp_function);
key = emalloc(key_len + 1);
zend_str_tolower_copy(key, Z_STRVAL_PP(tmp_function), key_len);
if (zend_hash_find(EG(function_table), key, key_len+1, (void**)&f) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to add a non existent function '%s'", Z_STRVAL_PP(tmp_function));
return;
}
MAKE_STD_ZVAL(function_copy);
ZVAL_STRING(function_copy, f->common.function_name, 1);
zend_hash_update(service->soap_functions.ft, key, key_len+1, &function_copy, sizeof(zval *), NULL);
efree(key);
zend_hash_move_forward_ex(Z_ARRVAL_P(function_name), &pos);
}
}
} else if (function_name->type == IS_STRING) {
char *key;
int key_len;
zend_function *f;
key_len = Z_STRLEN_P(function_name);
key = emalloc(key_len + 1);
zend_str_tolower_copy(key, Z_STRVAL_P(function_name), key_len);
if (zend_hash_find(EG(function_table), key, key_len+1, (void**)&f) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to add a non existent function '%s'", Z_STRVAL_P(function_name));
return;
}
if (service->soap_functions.ft == NULL) {
service->soap_functions.functions_all = FALSE;
service->soap_functions.ft = emalloc(sizeof(HashTable));
zend_hash_init(service->soap_functions.ft, 0, NULL, ZVAL_PTR_DTOR, 0);
}
MAKE_STD_ZVAL(function_copy);
ZVAL_STRING(function_copy, f->common.function_name, 1);
zend_hash_update(service->soap_functions.ft, key, key_len+1, &function_copy, sizeof(zval *), NULL);
efree(key);
} else if (function_name->type == IS_LONG) {
if (Z_LVAL_P(function_name) == SOAP_FUNCTIONS_ALL) {
if (service->soap_functions.ft != NULL) {
zend_hash_destroy(service->soap_functions.ft);
efree(service->soap_functions.ft);
service->soap_functions.ft = NULL;
}
service->soap_functions.functions_all = TRUE;
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value passed");
return;
}
}
SOAP_SERVER_END_CODE();
}
| @@ -2554,7 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -2594,7 +2594,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
ret = FALSE;
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
}
xmlFree(buf);
@@ -2633,13 +2633,13 @@ static void do_soap_call(zval* this_ptr,
SOAP_CLIENT_BEGIN_CODE();
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
- && Z_LVAL_PP(tmp) == SOAP_1_2) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
@@ -2735,7 +2735,7 @@ static void do_soap_call(zval* this_ptr,
zval **uri;
smart_str action = {0};
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3006,7 +3006,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3024,7 +3025,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3042,7 +3044,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3060,7 +3063,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3116,13 +3120,15 @@ PHP_METHOD(SoapClient, __setCookie)
}
if (val == NULL) {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
}
} else {
zval *zcookie;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
@@ -3150,7 +3156,8 @@ PHP_METHOD(SoapClient, __getCookies)
array_init(return_value);
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
}
}
@@ -4237,7 +4244,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
}
} else {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
+ Z_TYPE_PP(zstyle) == IS_LONG) {
style = Z_LVAL_PP(zstyle);
} else {
style = SOAP_RPC;
@@ -4260,7 +4268,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
- Z_LVAL_PP(zuse) == SOAP_LITERAL) {
+ Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
@@ -4390,6 +4398,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
zval **param_data;
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS &&
+ Z_TYPE_PP(param_name) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name); | null | null | null |
11,934 | PHP_METHOD(SoapServer, handle)
{
int soap_version, old_soap_version;
sdlPtr old_sdl = NULL;
soapServicePtr service;
xmlDocPtr doc_request=NULL, doc_return;
zval function_name, **params, *soap_obj, *retval;
char *fn_name, cont_len[30];
int num_params = 0, size, i, call_status = 0;
xmlChar *buf;
HashTable *function_table;
soapHeader *soap_headers = NULL;
sdlFunctionPtr function;
char *arg = NULL;
int arg_len = 0;
xmlCharEncodingHandlerPtr old_encoding;
HashTable *old_class_map, *old_typemap;
int old_features;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
SOAP_GLOBAL(soap_version) = service->version;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &arg, &arg_len) == FAILURE) {
return;
}
if (SG(request_info).request_method &&
strcmp(SG(request_info).request_method, "GET") == 0 &&
SG(request_info).query_string &&
stricmp(SG(request_info).query_string, "wsdl") == 0) {
if (service->sdl) {
/*
char *hdr = emalloc(sizeof("Location: ")+strlen(service->sdl->source));
strcpy(hdr,"Location: ");
strcat(hdr,service->sdl->source);
sapi_add_header(hdr, sizeof("Location: ")+strlen(service->sdl->source)-1, 1);
efree(hdr);
*/
zval readfile, readfile_ret, *param;
INIT_ZVAL(readfile);
INIT_ZVAL(readfile_ret);
MAKE_STD_ZVAL(param);
sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);
ZVAL_STRING(param, service->sdl->source, 1);
ZVAL_STRING(&readfile, "readfile", 1);
if (call_user_function(EG(function_table), NULL, &readfile, &readfile_ret, 1, ¶m TSRMLS_CC) == FAILURE) {
soap_server_fault("Server", "Couldn't find WSDL", NULL, NULL, NULL TSRMLS_CC);
}
zval_ptr_dtor(¶m);
zval_dtor(&readfile);
zval_dtor(&readfile_ret);
SOAP_SERVER_END_CODE();
return;
} else {
soap_server_fault("Server", "WSDL generation is not supported yet", NULL, NULL, NULL TSRMLS_CC);
/*
sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8"), 1);
PUTS("<?xml version=\"1.0\" ?>\n<definitions\n");
PUTS(" xmlns=\"http://schemas.xmlsoap.org/wsdl/\"\n");
PUTS(" targetNamespace=\"");
PUTS(service->uri);
PUTS("\">\n");
PUTS("</definitions>");
*/
SOAP_SERVER_END_CODE();
return;
}
}
ALLOC_INIT_ZVAL(retval);
if (php_output_start_default(TSRMLS_C) != SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_ERROR,"ob_start failed");
}
if (ZEND_NUM_ARGS() == 0) {
if (SG(request_info).raw_post_data) {
char *post_data = SG(request_info).raw_post_data;
int post_data_length = SG(request_info).raw_post_data_length;
zval **server_vars, **encoding;
zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC);
if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **) &server_vars) == SUCCESS &&
Z_TYPE_PP(server_vars) == IS_ARRAY &&
zend_hash_find(Z_ARRVAL_PP(server_vars), "HTTP_CONTENT_ENCODING", sizeof("HTTP_CONTENT_ENCODING"), (void **) &encoding)==SUCCESS &&
Z_TYPE_PP(encoding) == IS_STRING) {
zval func;
zval retval;
zval param;
zval *params[1];
if ((strcmp(Z_STRVAL_PP(encoding),"gzip") == 0 ||
strcmp(Z_STRVAL_PP(encoding),"x-gzip") == 0) &&
zend_hash_exists(EG(function_table), "gzinflate", sizeof("gzinflate"))) {
ZVAL_STRING(&func, "gzinflate", 0);
params[0] = ¶m;
ZVAL_STRINGL(params[0], post_data+10, post_data_length-10, 0);
INIT_PZVAL(params[0]);
} else if (strcmp(Z_STRVAL_PP(encoding),"deflate") == 0 &&
zend_hash_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress"))) {
ZVAL_STRING(&func, "gzuncompress", 0);
params[0] = ¶m;
ZVAL_STRINGL(params[0], post_data, post_data_length, 0);
INIT_PZVAL(params[0]);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Request is compressed with unknown compression '%s'",Z_STRVAL_PP(encoding));
return;
}
if (call_user_function(CG(function_table), (zval**)NULL, &func, &retval, 1, params TSRMLS_CC) == SUCCESS &&
Z_TYPE(retval) == IS_STRING) {
doc_request = soap_xmlParseMemory(Z_STRVAL(retval),Z_STRLEN(retval));
zval_dtor(&retval);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Can't uncompress compressed request");
return;
}
} else {
doc_request = soap_xmlParseMemory(post_data, post_data_length);
}
} else {
zval_ptr_dtor(&retval);
return;
}
} else {
doc_request = soap_xmlParseMemory(arg,arg_len);
}
if (doc_request == NULL) {
soap_server_fault("Client", "Bad Request", NULL, NULL, NULL TSRMLS_CC);
}
if (xmlGetIntSubset(doc_request) != NULL) {
xmlNodePtr env = get_node(doc_request->children,"Envelope");
if (env && env->ns) {
if (strcmp((char*)env->ns->href, SOAP_1_1_ENV_NAMESPACE) == 0) {
SOAP_GLOBAL(soap_version) = SOAP_1_1;
} else if (strcmp((char*)env->ns->href,SOAP_1_2_ENV_NAMESPACE) == 0) {
SOAP_GLOBAL(soap_version) = SOAP_1_2;
}
}
xmlFreeDoc(doc_request);
soap_server_fault("Server", "DTD are not supported by SOAP", NULL, NULL, NULL TSRMLS_CC);
}
old_sdl = SOAP_GLOBAL(sdl);
SOAP_GLOBAL(sdl) = service->sdl;
old_encoding = SOAP_GLOBAL(encoding);
SOAP_GLOBAL(encoding) = service->encoding;
old_class_map = SOAP_GLOBAL(class_map);
SOAP_GLOBAL(class_map) = service->class_map;
old_typemap = SOAP_GLOBAL(typemap);
SOAP_GLOBAL(typemap) = service->typemap;
old_features = SOAP_GLOBAL(features);
SOAP_GLOBAL(features) = service->features;
old_soap_version = SOAP_GLOBAL(soap_version);
function = deserialize_function_call(service->sdl, doc_request, service->actor, &function_name, &num_params, ¶ms, &soap_version, &soap_headers TSRMLS_CC);
xmlFreeDoc(doc_request);
if (EG(exception)) {
php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
}
goto fail;
}
service->soap_headers_ptr = &soap_headers;
soap_obj = NULL;
if (service->type == SOAP_OBJECT) {
soap_obj = service->soap_object;
function_table = &((Z_OBJCE_P(soap_obj))->function_table);
} else if (service->type == SOAP_CLASS) {
#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
/* If persistent then set soap_obj from from the previous created session (if available) */
if (service->soap_class.persistance == SOAP_PERSISTENCE_SESSION) {
zval **tmp_soap;
if (PS(session_status) != php_session_active &&
PS(session_status) != php_session_disabled) {
php_session_start(TSRMLS_C);
}
/* Find the soap object and assign */
if (zend_hash_find(Z_ARRVAL_P(PS(http_session_vars)), "_bogus_session_name", sizeof("_bogus_session_name"), (void **) &tmp_soap) == SUCCESS &&
Z_TYPE_PP(tmp_soap) == IS_OBJECT &&
Z_OBJCE_PP(tmp_soap) == service->soap_class.ce) {
soap_obj = *tmp_soap;
}
}
#endif
/* If new session or something weird happned */
if (soap_obj == NULL) {
zval *tmp_soap;
MAKE_STD_ZVAL(tmp_soap);
object_init_ex(tmp_soap, service->soap_class.ce);
/* Call constructor */
if (zend_hash_exists(&Z_OBJCE_P(tmp_soap)->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME))) {
zval c_ret, constructor;
INIT_ZVAL(c_ret);
INIT_ZVAL(constructor);
ZVAL_STRING(&constructor, ZEND_CONSTRUCTOR_FUNC_NAME, 1);
if (call_user_function(NULL, &tmp_soap, &constructor, &c_ret, service->soap_class.argc, service->soap_class.argv TSRMLS_CC) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error calling constructor");
}
if (EG(exception)) {
php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
}
zval_dtor(&constructor);
zval_dtor(&c_ret);
zval_ptr_dtor(&tmp_soap);
goto fail;
}
zval_dtor(&constructor);
zval_dtor(&c_ret);
} else {
int class_name_len = strlen(service->soap_class.ce->name);
char *class_name = emalloc(class_name_len+1);
memcpy(class_name, service->soap_class.ce->name,class_name_len+1);
if (zend_hash_exists(&Z_OBJCE_P(tmp_soap)->function_table, php_strtolower(class_name, class_name_len), class_name_len+1)) {
zval c_ret, constructor;
INIT_ZVAL(c_ret);
INIT_ZVAL(constructor);
ZVAL_STRING(&constructor, service->soap_class.ce->name, 1);
if (call_user_function(NULL, &tmp_soap, &constructor, &c_ret, service->soap_class.argc, service->soap_class.argv TSRMLS_CC) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error calling constructor");
}
if (EG(exception)) {
php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
}
zval_dtor(&constructor);
zval_dtor(&c_ret);
efree(class_name);
zval_ptr_dtor(&tmp_soap);
goto fail;
}
zval_dtor(&constructor);
zval_dtor(&c_ret);
}
efree(class_name);
}
#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
/* If session then update session hash with new object */
if (service->soap_class.persistance == SOAP_PERSISTENCE_SESSION) {
zval **tmp_soap_pp;
if (zend_hash_update(Z_ARRVAL_P(PS(http_session_vars)), "_bogus_session_name", sizeof("_bogus_session_name"), &tmp_soap, sizeof(zval *), (void **)&tmp_soap_pp) == SUCCESS) {
soap_obj = *tmp_soap_pp;
}
} else {
soap_obj = tmp_soap;
}
#else
soap_obj = tmp_soap;
#endif
}
function_table = &((Z_OBJCE_P(soap_obj))->function_table);
} else {
if (service->soap_functions.functions_all == TRUE) {
function_table = EG(function_table);
} else {
function_table = service->soap_functions.ft;
}
}
doc_return = NULL;
/* Process soap headers */
if (soap_headers != NULL) {
soapHeader *header = soap_headers;
while (header != NULL) {
soapHeader *h = header;
header = header->next;
#if 0
if (service->sdl && !h->function && !h->hdr) {
if (h->mustUnderstand) {
soap_server_fault("MustUnderstand","Header not understood", NULL, NULL, NULL TSRMLS_CC);
} else {
continue;
}
}
#endif
fn_name = estrndup(Z_STRVAL(h->function_name),Z_STRLEN(h->function_name));
if (zend_hash_exists(function_table, php_strtolower(fn_name, Z_STRLEN(h->function_name)), Z_STRLEN(h->function_name) + 1) ||
((service->type == SOAP_CLASS || service->type == SOAP_OBJECT) &&
zend_hash_exists(function_table, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)))) {
if (service->type == SOAP_CLASS || service->type == SOAP_OBJECT) {
call_status = call_user_function(NULL, &soap_obj, &h->function_name, &h->retval, h->num_params, h->parameters TSRMLS_CC);
} else {
call_status = call_user_function(EG(function_table), NULL, &h->function_name, &h->retval, h->num_params, h->parameters TSRMLS_CC);
}
if (call_status != SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function '%s' call failed", Z_STRVAL(h->function_name));
return;
}
if (Z_TYPE(h->retval) == IS_OBJECT &&
instanceof_function(Z_OBJCE(h->retval), soap_fault_class_entry TSRMLS_CC)) {
zval *headerfault = NULL, **tmp;
if (zend_hash_find(Z_OBJPROP(h->retval), "headerfault", sizeof("headerfault"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) != IS_NULL) {
headerfault = *tmp;
}
php_output_discard(TSRMLS_C);
soap_server_fault_ex(function, &h->retval, h TSRMLS_CC);
efree(fn_name);
if (service->type == SOAP_CLASS && soap_obj) {zval_ptr_dtor(&soap_obj);}
goto fail;
} else if (EG(exception)) {
php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
zval *headerfault = NULL, **tmp;
if (zend_hash_find(Z_OBJPROP_P(EG(exception)), "headerfault", sizeof("headerfault"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) != IS_NULL) {
headerfault = *tmp;
}
soap_server_fault_ex(function, EG(exception), h TSRMLS_CC);
}
efree(fn_name);
if (service->type == SOAP_CLASS && soap_obj) {zval_ptr_dtor(&soap_obj);}
goto fail;
}
} else if (h->mustUnderstand) {
soap_server_fault("MustUnderstand","Header not understood", NULL, NULL, NULL TSRMLS_CC);
}
efree(fn_name);
}
}
fn_name = estrndup(Z_STRVAL(function_name),Z_STRLEN(function_name));
if (zend_hash_exists(function_table, php_strtolower(fn_name, Z_STRLEN(function_name)), Z_STRLEN(function_name) + 1) ||
((service->type == SOAP_CLASS || service->type == SOAP_OBJECT) &&
zend_hash_exists(function_table, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)))) {
if (service->type == SOAP_CLASS || service->type == SOAP_OBJECT) {
call_status = call_user_function(NULL, &soap_obj, &function_name, retval, num_params, params TSRMLS_CC);
if (service->type == SOAP_CLASS) {
#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
if (service->soap_class.persistance != SOAP_PERSISTENCE_SESSION) {
zval_ptr_dtor(&soap_obj);
soap_obj = NULL;
}
#else
zval_ptr_dtor(&soap_obj);
soap_obj = NULL;
#endif
}
} else {
call_status = call_user_function(EG(function_table), NULL, &function_name, retval, num_params, params TSRMLS_CC);
}
} else {
php_error(E_ERROR, "Function '%s' doesn't exist", Z_STRVAL(function_name));
}
efree(fn_name);
if (EG(exception)) {
php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
}
if (service->type == SOAP_CLASS) {
#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
if (soap_obj && service->soap_class.persistance != SOAP_PERSISTENCE_SESSION) {
#else
if (soap_obj) {
#endif
zval_ptr_dtor(&soap_obj);
}
}
goto fail;
}
if (call_status == SUCCESS) {
char *response_name;
if (Z_TYPE_P(retval) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(retval), soap_fault_class_entry TSRMLS_CC)) {
php_output_discard(TSRMLS_C);
soap_server_fault_ex(function, retval, NULL TSRMLS_CC);
goto fail;
}
if (function && function->responseName) {
response_name = estrdup(function->responseName);
} else {
response_name = emalloc(Z_STRLEN(function_name) + sizeof("Response"));
memcpy(response_name,Z_STRVAL(function_name),Z_STRLEN(function_name));
memcpy(response_name+Z_STRLEN(function_name),"Response",sizeof("Response"));
}
doc_return = serialize_response_call(function, response_name, service->uri, retval, soap_headers, soap_version TSRMLS_CC);
efree(response_name);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function '%s' call failed", Z_STRVAL(function_name));
return;
}
if (EG(exception)) {
php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
}
if (service->type == SOAP_CLASS) {
#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
if (soap_obj && service->soap_class.persistance != SOAP_PERSISTENCE_SESSION) {
#else
if (soap_obj) {
#endif
zval_ptr_dtor(&soap_obj);
}
}
goto fail;
}
/* Flush buffer */
php_output_discard(TSRMLS_C);
if (doc_return) {
/* xmlDocDumpMemoryEnc(doc_return, &buf, &size, XML_CHAR_ENCODING_UTF8); */
xmlDocDumpMemory(doc_return, &buf, &size);
if (size == 0) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Dump memory failed");
}
if (soap_version == SOAP_1_2) {
sapi_add_header("Content-Type: application/soap+xml; charset=utf-8", sizeof("Content-Type: application/soap+xml; charset=utf-8")-1, 1);
} else {
sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);
}
xmlFreeDoc(doc_return);
if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0)) {
sapi_add_header("Connection: close", sizeof("Connection: close")-1, 1);
} else {
snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", size);
sapi_add_header(cont_len, strlen(cont_len), 1);
}
php_write(buf, size TSRMLS_CC);
xmlFree(buf);
} else {
sapi_add_header("HTTP/1.1 202 Accepted", sizeof("HTTP/1.1 202 Accepted")-1, 1);
sapi_add_header("Content-Length: 0", sizeof("Content-Length: 0")-1, 1);
}
fail:
SOAP_GLOBAL(soap_version) = old_soap_version;
SOAP_GLOBAL(encoding) = old_encoding;
SOAP_GLOBAL(sdl) = old_sdl;
SOAP_GLOBAL(class_map) = old_class_map;
SOAP_GLOBAL(typemap) = old_typemap;
SOAP_GLOBAL(features) = old_features;
/* Free soap headers */
zval_ptr_dtor(&retval);
while (soap_headers != NULL) {
soapHeader *h = soap_headers;
int i;
soap_headers = soap_headers->next;
if (h->parameters) {
i = h->num_params;
while (i > 0) {
zval_ptr_dtor(&h->parameters[--i]);
}
efree(h->parameters);
}
zval_dtor(&h->function_name);
zval_dtor(&h->retval);
efree(h);
}
service->soap_headers_ptr = NULL;
/* Free Memory */
if (num_params > 0) {
for (i = 0; i < num_params;i++) {
zval_ptr_dtor(¶ms[i]);
}
efree(params);
}
zval_dtor(&function_name);
SOAP_SERVER_END_CODE();
}
/* }}} */
/* {{{ proto SoapServer::fault ( staring code, string string [, string actor [, mixed details [, string name]]] )
Issue SoapFault indicating an error */
PHP_METHOD(SoapServer, fault)
{
char *code, *string, *actor=NULL, *name=NULL;
int code_len, string_len, actor_len = 0, name_len = 0;
zval* details = NULL;
soapServicePtr service;
xmlCharEncodingHandlerPtr old_encoding;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
old_encoding = SOAP_GLOBAL(encoding);
SOAP_GLOBAL(encoding) = service->encoding;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|szs",
&code, &code_len, &string, &string_len, &actor, &actor_len, &details,
&name, &name_len) == FAILURE) {
return;
}
soap_server_fault(code, string, actor, details, name TSRMLS_CC);
SOAP_GLOBAL(encoding) = old_encoding;
SOAP_SERVER_END_CODE();
}
/* }}} */
PHP_METHOD(SoapServer, addSoapHeader)
{
| DoS Exec Code | 0 | PHP_METHOD(SoapServer, handle)
{
int soap_version, old_soap_version;
sdlPtr old_sdl = NULL;
soapServicePtr service;
xmlDocPtr doc_request=NULL, doc_return;
zval function_name, **params, *soap_obj, *retval;
char *fn_name, cont_len[30];
int num_params = 0, size, i, call_status = 0;
xmlChar *buf;
HashTable *function_table;
soapHeader *soap_headers = NULL;
sdlFunctionPtr function;
char *arg = NULL;
int arg_len = 0;
xmlCharEncodingHandlerPtr old_encoding;
HashTable *old_class_map, *old_typemap;
int old_features;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
SOAP_GLOBAL(soap_version) = service->version;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &arg, &arg_len) == FAILURE) {
return;
}
if (SG(request_info).request_method &&
strcmp(SG(request_info).request_method, "GET") == 0 &&
SG(request_info).query_string &&
stricmp(SG(request_info).query_string, "wsdl") == 0) {
if (service->sdl) {
/*
char *hdr = emalloc(sizeof("Location: ")+strlen(service->sdl->source));
strcpy(hdr,"Location: ");
strcat(hdr,service->sdl->source);
sapi_add_header(hdr, sizeof("Location: ")+strlen(service->sdl->source)-1, 1);
efree(hdr);
*/
zval readfile, readfile_ret, *param;
INIT_ZVAL(readfile);
INIT_ZVAL(readfile_ret);
MAKE_STD_ZVAL(param);
sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);
ZVAL_STRING(param, service->sdl->source, 1);
ZVAL_STRING(&readfile, "readfile", 1);
if (call_user_function(EG(function_table), NULL, &readfile, &readfile_ret, 1, ¶m TSRMLS_CC) == FAILURE) {
soap_server_fault("Server", "Couldn't find WSDL", NULL, NULL, NULL TSRMLS_CC);
}
zval_ptr_dtor(¶m);
zval_dtor(&readfile);
zval_dtor(&readfile_ret);
SOAP_SERVER_END_CODE();
return;
} else {
soap_server_fault("Server", "WSDL generation is not supported yet", NULL, NULL, NULL TSRMLS_CC);
/*
sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8"), 1);
PUTS("<?xml version=\"1.0\" ?>\n<definitions\n");
PUTS(" xmlns=\"http://schemas.xmlsoap.org/wsdl/\"\n");
PUTS(" targetNamespace=\"");
PUTS(service->uri);
PUTS("\">\n");
PUTS("</definitions>");
*/
SOAP_SERVER_END_CODE();
return;
}
}
ALLOC_INIT_ZVAL(retval);
if (php_output_start_default(TSRMLS_C) != SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_ERROR,"ob_start failed");
}
if (ZEND_NUM_ARGS() == 0) {
if (SG(request_info).raw_post_data) {
char *post_data = SG(request_info).raw_post_data;
int post_data_length = SG(request_info).raw_post_data_length;
zval **server_vars, **encoding;
zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC);
if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **) &server_vars) == SUCCESS &&
Z_TYPE_PP(server_vars) == IS_ARRAY &&
zend_hash_find(Z_ARRVAL_PP(server_vars), "HTTP_CONTENT_ENCODING", sizeof("HTTP_CONTENT_ENCODING"), (void **) &encoding)==SUCCESS &&
Z_TYPE_PP(encoding) == IS_STRING) {
zval func;
zval retval;
zval param;
zval *params[1];
if ((strcmp(Z_STRVAL_PP(encoding),"gzip") == 0 ||
strcmp(Z_STRVAL_PP(encoding),"x-gzip") == 0) &&
zend_hash_exists(EG(function_table), "gzinflate", sizeof("gzinflate"))) {
ZVAL_STRING(&func, "gzinflate", 0);
params[0] = ¶m;
ZVAL_STRINGL(params[0], post_data+10, post_data_length-10, 0);
INIT_PZVAL(params[0]);
} else if (strcmp(Z_STRVAL_PP(encoding),"deflate") == 0 &&
zend_hash_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress"))) {
ZVAL_STRING(&func, "gzuncompress", 0);
params[0] = ¶m;
ZVAL_STRINGL(params[0], post_data, post_data_length, 0);
INIT_PZVAL(params[0]);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Request is compressed with unknown compression '%s'",Z_STRVAL_PP(encoding));
return;
}
if (call_user_function(CG(function_table), (zval**)NULL, &func, &retval, 1, params TSRMLS_CC) == SUCCESS &&
Z_TYPE(retval) == IS_STRING) {
doc_request = soap_xmlParseMemory(Z_STRVAL(retval),Z_STRLEN(retval));
zval_dtor(&retval);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING,"Can't uncompress compressed request");
return;
}
} else {
doc_request = soap_xmlParseMemory(post_data, post_data_length);
}
} else {
zval_ptr_dtor(&retval);
return;
}
} else {
doc_request = soap_xmlParseMemory(arg,arg_len);
}
if (doc_request == NULL) {
soap_server_fault("Client", "Bad Request", NULL, NULL, NULL TSRMLS_CC);
}
if (xmlGetIntSubset(doc_request) != NULL) {
xmlNodePtr env = get_node(doc_request->children,"Envelope");
if (env && env->ns) {
if (strcmp((char*)env->ns->href, SOAP_1_1_ENV_NAMESPACE) == 0) {
SOAP_GLOBAL(soap_version) = SOAP_1_1;
} else if (strcmp((char*)env->ns->href,SOAP_1_2_ENV_NAMESPACE) == 0) {
SOAP_GLOBAL(soap_version) = SOAP_1_2;
}
}
xmlFreeDoc(doc_request);
soap_server_fault("Server", "DTD are not supported by SOAP", NULL, NULL, NULL TSRMLS_CC);
}
old_sdl = SOAP_GLOBAL(sdl);
SOAP_GLOBAL(sdl) = service->sdl;
old_encoding = SOAP_GLOBAL(encoding);
SOAP_GLOBAL(encoding) = service->encoding;
old_class_map = SOAP_GLOBAL(class_map);
SOAP_GLOBAL(class_map) = service->class_map;
old_typemap = SOAP_GLOBAL(typemap);
SOAP_GLOBAL(typemap) = service->typemap;
old_features = SOAP_GLOBAL(features);
SOAP_GLOBAL(features) = service->features;
old_soap_version = SOAP_GLOBAL(soap_version);
function = deserialize_function_call(service->sdl, doc_request, service->actor, &function_name, &num_params, ¶ms, &soap_version, &soap_headers TSRMLS_CC);
xmlFreeDoc(doc_request);
if (EG(exception)) {
php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
}
goto fail;
}
service->soap_headers_ptr = &soap_headers;
soap_obj = NULL;
if (service->type == SOAP_OBJECT) {
soap_obj = service->soap_object;
function_table = &((Z_OBJCE_P(soap_obj))->function_table);
} else if (service->type == SOAP_CLASS) {
#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
/* If persistent then set soap_obj from from the previous created session (if available) */
if (service->soap_class.persistance == SOAP_PERSISTENCE_SESSION) {
zval **tmp_soap;
if (PS(session_status) != php_session_active &&
PS(session_status) != php_session_disabled) {
php_session_start(TSRMLS_C);
}
/* Find the soap object and assign */
if (zend_hash_find(Z_ARRVAL_P(PS(http_session_vars)), "_bogus_session_name", sizeof("_bogus_session_name"), (void **) &tmp_soap) == SUCCESS &&
Z_TYPE_PP(tmp_soap) == IS_OBJECT &&
Z_OBJCE_PP(tmp_soap) == service->soap_class.ce) {
soap_obj = *tmp_soap;
}
}
#endif
/* If new session or something weird happned */
if (soap_obj == NULL) {
zval *tmp_soap;
MAKE_STD_ZVAL(tmp_soap);
object_init_ex(tmp_soap, service->soap_class.ce);
/* Call constructor */
if (zend_hash_exists(&Z_OBJCE_P(tmp_soap)->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME))) {
zval c_ret, constructor;
INIT_ZVAL(c_ret);
INIT_ZVAL(constructor);
ZVAL_STRING(&constructor, ZEND_CONSTRUCTOR_FUNC_NAME, 1);
if (call_user_function(NULL, &tmp_soap, &constructor, &c_ret, service->soap_class.argc, service->soap_class.argv TSRMLS_CC) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error calling constructor");
}
if (EG(exception)) {
php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
}
zval_dtor(&constructor);
zval_dtor(&c_ret);
zval_ptr_dtor(&tmp_soap);
goto fail;
}
zval_dtor(&constructor);
zval_dtor(&c_ret);
} else {
int class_name_len = strlen(service->soap_class.ce->name);
char *class_name = emalloc(class_name_len+1);
memcpy(class_name, service->soap_class.ce->name,class_name_len+1);
if (zend_hash_exists(&Z_OBJCE_P(tmp_soap)->function_table, php_strtolower(class_name, class_name_len), class_name_len+1)) {
zval c_ret, constructor;
INIT_ZVAL(c_ret);
INIT_ZVAL(constructor);
ZVAL_STRING(&constructor, service->soap_class.ce->name, 1);
if (call_user_function(NULL, &tmp_soap, &constructor, &c_ret, service->soap_class.argc, service->soap_class.argv TSRMLS_CC) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error calling constructor");
}
if (EG(exception)) {
php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
}
zval_dtor(&constructor);
zval_dtor(&c_ret);
efree(class_name);
zval_ptr_dtor(&tmp_soap);
goto fail;
}
zval_dtor(&constructor);
zval_dtor(&c_ret);
}
efree(class_name);
}
#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
/* If session then update session hash with new object */
if (service->soap_class.persistance == SOAP_PERSISTENCE_SESSION) {
zval **tmp_soap_pp;
if (zend_hash_update(Z_ARRVAL_P(PS(http_session_vars)), "_bogus_session_name", sizeof("_bogus_session_name"), &tmp_soap, sizeof(zval *), (void **)&tmp_soap_pp) == SUCCESS) {
soap_obj = *tmp_soap_pp;
}
} else {
soap_obj = tmp_soap;
}
#else
soap_obj = tmp_soap;
#endif
}
function_table = &((Z_OBJCE_P(soap_obj))->function_table);
} else {
if (service->soap_functions.functions_all == TRUE) {
function_table = EG(function_table);
} else {
function_table = service->soap_functions.ft;
}
}
doc_return = NULL;
/* Process soap headers */
if (soap_headers != NULL) {
soapHeader *header = soap_headers;
while (header != NULL) {
soapHeader *h = header;
header = header->next;
#if 0
if (service->sdl && !h->function && !h->hdr) {
if (h->mustUnderstand) {
soap_server_fault("MustUnderstand","Header not understood", NULL, NULL, NULL TSRMLS_CC);
} else {
continue;
}
}
#endif
fn_name = estrndup(Z_STRVAL(h->function_name),Z_STRLEN(h->function_name));
if (zend_hash_exists(function_table, php_strtolower(fn_name, Z_STRLEN(h->function_name)), Z_STRLEN(h->function_name) + 1) ||
((service->type == SOAP_CLASS || service->type == SOAP_OBJECT) &&
zend_hash_exists(function_table, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)))) {
if (service->type == SOAP_CLASS || service->type == SOAP_OBJECT) {
call_status = call_user_function(NULL, &soap_obj, &h->function_name, &h->retval, h->num_params, h->parameters TSRMLS_CC);
} else {
call_status = call_user_function(EG(function_table), NULL, &h->function_name, &h->retval, h->num_params, h->parameters TSRMLS_CC);
}
if (call_status != SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function '%s' call failed", Z_STRVAL(h->function_name));
return;
}
if (Z_TYPE(h->retval) == IS_OBJECT &&
instanceof_function(Z_OBJCE(h->retval), soap_fault_class_entry TSRMLS_CC)) {
zval *headerfault = NULL, **tmp;
if (zend_hash_find(Z_OBJPROP(h->retval), "headerfault", sizeof("headerfault"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) != IS_NULL) {
headerfault = *tmp;
}
php_output_discard(TSRMLS_C);
soap_server_fault_ex(function, &h->retval, h TSRMLS_CC);
efree(fn_name);
if (service->type == SOAP_CLASS && soap_obj) {zval_ptr_dtor(&soap_obj);}
goto fail;
} else if (EG(exception)) {
php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
zval *headerfault = NULL, **tmp;
if (zend_hash_find(Z_OBJPROP_P(EG(exception)), "headerfault", sizeof("headerfault"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) != IS_NULL) {
headerfault = *tmp;
}
soap_server_fault_ex(function, EG(exception), h TSRMLS_CC);
}
efree(fn_name);
if (service->type == SOAP_CLASS && soap_obj) {zval_ptr_dtor(&soap_obj);}
goto fail;
}
} else if (h->mustUnderstand) {
soap_server_fault("MustUnderstand","Header not understood", NULL, NULL, NULL TSRMLS_CC);
}
efree(fn_name);
}
}
fn_name = estrndup(Z_STRVAL(function_name),Z_STRLEN(function_name));
if (zend_hash_exists(function_table, php_strtolower(fn_name, Z_STRLEN(function_name)), Z_STRLEN(function_name) + 1) ||
((service->type == SOAP_CLASS || service->type == SOAP_OBJECT) &&
zend_hash_exists(function_table, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)))) {
if (service->type == SOAP_CLASS || service->type == SOAP_OBJECT) {
call_status = call_user_function(NULL, &soap_obj, &function_name, retval, num_params, params TSRMLS_CC);
if (service->type == SOAP_CLASS) {
#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
if (service->soap_class.persistance != SOAP_PERSISTENCE_SESSION) {
zval_ptr_dtor(&soap_obj);
soap_obj = NULL;
}
#else
zval_ptr_dtor(&soap_obj);
soap_obj = NULL;
#endif
}
} else {
call_status = call_user_function(EG(function_table), NULL, &function_name, retval, num_params, params TSRMLS_CC);
}
} else {
php_error(E_ERROR, "Function '%s' doesn't exist", Z_STRVAL(function_name));
}
efree(fn_name);
if (EG(exception)) {
php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
}
if (service->type == SOAP_CLASS) {
#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
if (soap_obj && service->soap_class.persistance != SOAP_PERSISTENCE_SESSION) {
#else
if (soap_obj) {
#endif
zval_ptr_dtor(&soap_obj);
}
}
goto fail;
}
if (call_status == SUCCESS) {
char *response_name;
if (Z_TYPE_P(retval) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(retval), soap_fault_class_entry TSRMLS_CC)) {
php_output_discard(TSRMLS_C);
soap_server_fault_ex(function, retval, NULL TSRMLS_CC);
goto fail;
}
if (function && function->responseName) {
response_name = estrdup(function->responseName);
} else {
response_name = emalloc(Z_STRLEN(function_name) + sizeof("Response"));
memcpy(response_name,Z_STRVAL(function_name),Z_STRLEN(function_name));
memcpy(response_name+Z_STRLEN(function_name),"Response",sizeof("Response"));
}
doc_return = serialize_response_call(function, response_name, service->uri, retval, soap_headers, soap_version TSRMLS_CC);
efree(response_name);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function '%s' call failed", Z_STRVAL(function_name));
return;
}
if (EG(exception)) {
php_output_discard(TSRMLS_C);
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
}
if (service->type == SOAP_CLASS) {
#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
if (soap_obj && service->soap_class.persistance != SOAP_PERSISTENCE_SESSION) {
#else
if (soap_obj) {
#endif
zval_ptr_dtor(&soap_obj);
}
}
goto fail;
}
/* Flush buffer */
php_output_discard(TSRMLS_C);
if (doc_return) {
/* xmlDocDumpMemoryEnc(doc_return, &buf, &size, XML_CHAR_ENCODING_UTF8); */
xmlDocDumpMemory(doc_return, &buf, &size);
if (size == 0) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Dump memory failed");
}
if (soap_version == SOAP_1_2) {
sapi_add_header("Content-Type: application/soap+xml; charset=utf-8", sizeof("Content-Type: application/soap+xml; charset=utf-8")-1, 1);
} else {
sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);
}
xmlFreeDoc(doc_return);
if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0)) {
sapi_add_header("Connection: close", sizeof("Connection: close")-1, 1);
} else {
snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", size);
sapi_add_header(cont_len, strlen(cont_len), 1);
}
php_write(buf, size TSRMLS_CC);
xmlFree(buf);
} else {
sapi_add_header("HTTP/1.1 202 Accepted", sizeof("HTTP/1.1 202 Accepted")-1, 1);
sapi_add_header("Content-Length: 0", sizeof("Content-Length: 0")-1, 1);
}
fail:
SOAP_GLOBAL(soap_version) = old_soap_version;
SOAP_GLOBAL(encoding) = old_encoding;
SOAP_GLOBAL(sdl) = old_sdl;
SOAP_GLOBAL(class_map) = old_class_map;
SOAP_GLOBAL(typemap) = old_typemap;
SOAP_GLOBAL(features) = old_features;
/* Free soap headers */
zval_ptr_dtor(&retval);
while (soap_headers != NULL) {
soapHeader *h = soap_headers;
int i;
soap_headers = soap_headers->next;
if (h->parameters) {
i = h->num_params;
while (i > 0) {
zval_ptr_dtor(&h->parameters[--i]);
}
efree(h->parameters);
}
zval_dtor(&h->function_name);
zval_dtor(&h->retval);
efree(h);
}
service->soap_headers_ptr = NULL;
/* Free Memory */
if (num_params > 0) {
for (i = 0; i < num_params;i++) {
zval_ptr_dtor(¶ms[i]);
}
efree(params);
}
zval_dtor(&function_name);
SOAP_SERVER_END_CODE();
}
/* }}} */
/* {{{ proto SoapServer::fault ( staring code, string string [, string actor [, mixed details [, string name]]] )
Issue SoapFault indicating an error */
PHP_METHOD(SoapServer, fault)
{
char *code, *string, *actor=NULL, *name=NULL;
int code_len, string_len, actor_len = 0, name_len = 0;
zval* details = NULL;
soapServicePtr service;
xmlCharEncodingHandlerPtr old_encoding;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
old_encoding = SOAP_GLOBAL(encoding);
SOAP_GLOBAL(encoding) = service->encoding;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|szs",
&code, &code_len, &string, &string_len, &actor, &actor_len, &details,
&name, &name_len) == FAILURE) {
return;
}
soap_server_fault(code, string, actor, details, name TSRMLS_CC);
SOAP_GLOBAL(encoding) = old_encoding;
SOAP_SERVER_END_CODE();
}
/* }}} */
PHP_METHOD(SoapServer, addSoapHeader)
{
| @@ -2554,7 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -2594,7 +2594,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
ret = FALSE;
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
}
xmlFree(buf);
@@ -2633,13 +2633,13 @@ static void do_soap_call(zval* this_ptr,
SOAP_CLIENT_BEGIN_CODE();
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
- && Z_LVAL_PP(tmp) == SOAP_1_2) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
@@ -2735,7 +2735,7 @@ static void do_soap_call(zval* this_ptr,
zval **uri;
smart_str action = {0};
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3006,7 +3006,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3024,7 +3025,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3042,7 +3044,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3060,7 +3063,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3116,13 +3120,15 @@ PHP_METHOD(SoapClient, __setCookie)
}
if (val == NULL) {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
}
} else {
zval *zcookie;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
@@ -3150,7 +3156,8 @@ PHP_METHOD(SoapClient, __getCookies)
array_init(return_value);
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
}
}
@@ -4237,7 +4244,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
}
} else {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
+ Z_TYPE_PP(zstyle) == IS_LONG) {
style = Z_LVAL_PP(zstyle);
} else {
style = SOAP_RPC;
@@ -4260,7 +4268,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
- Z_LVAL_PP(zuse) == SOAP_LITERAL) {
+ Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
@@ -4390,6 +4398,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
zval **param_data;
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS &&
+ Z_TYPE_PP(param_name) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name); | null | null | null |
11,935 | PHP_METHOD(SoapServer, fault)
{
char *code, *string, *actor=NULL, *name=NULL;
int code_len, string_len, actor_len = 0, name_len = 0;
zval* details = NULL;
soapServicePtr service;
xmlCharEncodingHandlerPtr old_encoding;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
old_encoding = SOAP_GLOBAL(encoding);
SOAP_GLOBAL(encoding) = service->encoding;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|szs",
&code, &code_len, &string, &string_len, &actor, &actor_len, &details,
&name, &name_len) == FAILURE) {
return;
}
soap_server_fault(code, string, actor, details, name TSRMLS_CC);
SOAP_GLOBAL(encoding) = old_encoding;
SOAP_SERVER_END_CODE();
}
| DoS Exec Code | 0 | PHP_METHOD(SoapServer, fault)
{
char *code, *string, *actor=NULL, *name=NULL;
int code_len, string_len, actor_len = 0, name_len = 0;
zval* details = NULL;
soapServicePtr service;
xmlCharEncodingHandlerPtr old_encoding;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
old_encoding = SOAP_GLOBAL(encoding);
SOAP_GLOBAL(encoding) = service->encoding;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|szs",
&code, &code_len, &string, &string_len, &actor, &actor_len, &details,
&name, &name_len) == FAILURE) {
return;
}
soap_server_fault(code, string, actor, details, name TSRMLS_CC);
SOAP_GLOBAL(encoding) = old_encoding;
SOAP_SERVER_END_CODE();
}
| @@ -2554,7 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -2594,7 +2594,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
ret = FALSE;
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
}
xmlFree(buf);
@@ -2633,13 +2633,13 @@ static void do_soap_call(zval* this_ptr,
SOAP_CLIENT_BEGIN_CODE();
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
- && Z_LVAL_PP(tmp) == SOAP_1_2) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
@@ -2735,7 +2735,7 @@ static void do_soap_call(zval* this_ptr,
zval **uri;
smart_str action = {0};
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3006,7 +3006,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3024,7 +3025,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3042,7 +3044,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3060,7 +3063,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3116,13 +3120,15 @@ PHP_METHOD(SoapClient, __setCookie)
}
if (val == NULL) {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
}
} else {
zval *zcookie;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
@@ -3150,7 +3156,8 @@ PHP_METHOD(SoapClient, __getCookies)
array_init(return_value);
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
}
}
@@ -4237,7 +4244,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
}
} else {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
+ Z_TYPE_PP(zstyle) == IS_LONG) {
style = Z_LVAL_PP(zstyle);
} else {
style = SOAP_RPC;
@@ -4260,7 +4268,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
- Z_LVAL_PP(zuse) == SOAP_LITERAL) {
+ Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
@@ -4390,6 +4398,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
zval **param_data;
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS &&
+ Z_TYPE_PP(param_name) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name); | null | null | null |
11,936 | PHP_METHOD(SoapServer, addSoapHeader)
{
soapServicePtr service;
zval *fault;
soapHeader **p;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
if (!service || !service->soap_headers_ptr) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The SoapServer::addSoapHeader function may be called only during SOAP request processing");
return;
}
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &fault, soap_header_class_entry) == FAILURE) {
return;
}
p = service->soap_headers_ptr;
while (*p != NULL) {
p = &(*p)->next;
}
*p = emalloc(sizeof(soapHeader));
memset(*p, 0, sizeof(soapHeader));
ZVAL_NULL(&(*p)->function_name);
(*p)->retval = *fault;
zval_copy_ctor(&(*p)->retval);
SOAP_SERVER_END_CODE();
}
| DoS Exec Code | 0 | PHP_METHOD(SoapServer, addSoapHeader)
{
soapServicePtr service;
zval *fault;
soapHeader **p;
SOAP_SERVER_BEGIN_CODE();
FETCH_THIS_SERVICE(service);
if (!service || !service->soap_headers_ptr) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The SoapServer::addSoapHeader function may be called only during SOAP request processing");
return;
}
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &fault, soap_header_class_entry) == FAILURE) {
return;
}
p = service->soap_headers_ptr;
while (*p != NULL) {
p = &(*p)->next;
}
*p = emalloc(sizeof(soapHeader));
memset(*p, 0, sizeof(soapHeader));
ZVAL_NULL(&(*p)->function_name);
(*p)->retval = *fault;
zval_copy_ctor(&(*p)->retval);
SOAP_SERVER_END_CODE();
}
| @@ -2554,7 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -2594,7 +2594,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
ret = FALSE;
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
}
xmlFree(buf);
@@ -2633,13 +2633,13 @@ static void do_soap_call(zval* this_ptr,
SOAP_CLIENT_BEGIN_CODE();
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
- && Z_LVAL_PP(tmp) == SOAP_1_2) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
@@ -2735,7 +2735,7 @@ static void do_soap_call(zval* this_ptr,
zval **uri;
smart_str action = {0};
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3006,7 +3006,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3024,7 +3025,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3042,7 +3044,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3060,7 +3063,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3116,13 +3120,15 @@ PHP_METHOD(SoapClient, __setCookie)
}
if (val == NULL) {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
}
} else {
zval *zcookie;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
@@ -3150,7 +3156,8 @@ PHP_METHOD(SoapClient, __getCookies)
array_init(return_value);
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
}
}
@@ -4237,7 +4244,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
}
} else {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
+ Z_TYPE_PP(zstyle) == IS_LONG) {
style = Z_LVAL_PP(zstyle);
} else {
style = SOAP_RPC;
@@ -4260,7 +4268,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
- Z_LVAL_PP(zuse) == SOAP_LITERAL) {
+ Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
@@ -4390,6 +4398,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
zval **param_data;
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS &&
+ Z_TYPE_PP(param_name) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name); | null | null | null |
11,937 | PHP_METHOD(SoapClient, __call)
{
char *function, *location=NULL, *soap_action = NULL, *uri = NULL;
int function_len, i = 0;
HashTable* soap_headers = NULL;
zval *options = NULL;
zval *headers = NULL;
zval *output_headers = NULL;
zval *args;
zval **real_args = NULL;
zval **param;
int arg_count;
zval **tmp;
zend_bool free_soap_headers = 0;
HashPosition pos;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sa|a!zz",
&function, &function_len, &args, &options, &headers, &output_headers) == FAILURE) {
return;
}
if (options) {
HashTable *hto = Z_ARRVAL_P(options);
if (zend_hash_find(hto, "location", sizeof("location"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING) {
location = Z_STRVAL_PP(tmp);
}
if (zend_hash_find(hto, "soapaction", sizeof("soapaction"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING) {
soap_action = Z_STRVAL_PP(tmp);
}
if (zend_hash_find(hto, "uri", sizeof("uri"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING) {
uri = Z_STRVAL_PP(tmp);
}
}
if (headers == NULL || Z_TYPE_P(headers) == IS_NULL) {
} else if (Z_TYPE_P(headers) == IS_ARRAY) {
soap_headers = Z_ARRVAL_P(headers);
verify_soap_headers_array(soap_headers TSRMLS_CC);
free_soap_headers = 0;
} else if (Z_TYPE_P(headers) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(headers), soap_header_class_entry TSRMLS_CC)) {
soap_headers = emalloc(sizeof(HashTable));
zend_hash_init(soap_headers, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_next_index_insert(soap_headers, &headers, sizeof(zval*), NULL);
Z_ADDREF_P(headers);
free_soap_headers = 1;
} else{
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid SOAP header");
return;
}
/* Add default headers */
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__default_headers", sizeof("__default_headers"), (void **) &tmp)==SUCCESS &&
Z_TYPE_PP(tmp) == IS_ARRAY) {
HashTable *default_headers = Z_ARRVAL_P(*tmp);
if (soap_headers) {
if (!free_soap_headers) {
HashTable *t = emalloc(sizeof(HashTable));
zend_hash_init(t, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_copy(t, soap_headers, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
soap_headers = t;
free_soap_headers = 1;
}
zend_hash_internal_pointer_reset(default_headers);
while (zend_hash_get_current_data(default_headers, (void**)&tmp) == SUCCESS) {
Z_ADDREF_PP(tmp);
zend_hash_next_index_insert(soap_headers, tmp, sizeof(zval *), NULL);
zend_hash_move_forward(default_headers);
}
} else {
soap_headers = Z_ARRVAL_P(*tmp);
free_soap_headers = 0;
}
}
arg_count = zend_hash_num_elements(Z_ARRVAL_P(args));
if (arg_count > 0) {
real_args = safe_emalloc(sizeof(zval *), arg_count, 0);
for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(args), &pos);
zend_hash_get_current_data_ex(Z_ARRVAL_P(args), (void **) ¶m, &pos) == SUCCESS;
zend_hash_move_forward_ex(Z_ARRVAL_P(args), &pos)) {
/*zval_add_ref(param);*/
real_args[i++] = *param;
}
}
if (output_headers) {
array_init(output_headers);
}
do_soap_call(this_ptr, function, function_len, arg_count, real_args, return_value, location, soap_action, uri, soap_headers, output_headers TSRMLS_CC);
if (arg_count > 0) {
efree(real_args);
}
if (soap_headers && free_soap_headers) {
zend_hash_destroy(soap_headers);
efree(soap_headers);
}
}
| DoS Exec Code | 0 | PHP_METHOD(SoapClient, __call)
{
char *function, *location=NULL, *soap_action = NULL, *uri = NULL;
int function_len, i = 0;
HashTable* soap_headers = NULL;
zval *options = NULL;
zval *headers = NULL;
zval *output_headers = NULL;
zval *args;
zval **real_args = NULL;
zval **param;
int arg_count;
zval **tmp;
zend_bool free_soap_headers = 0;
HashPosition pos;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sa|a!zz",
&function, &function_len, &args, &options, &headers, &output_headers) == FAILURE) {
return;
}
if (options) {
HashTable *hto = Z_ARRVAL_P(options);
if (zend_hash_find(hto, "location", sizeof("location"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING) {
location = Z_STRVAL_PP(tmp);
}
if (zend_hash_find(hto, "soapaction", sizeof("soapaction"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING) {
soap_action = Z_STRVAL_PP(tmp);
}
if (zend_hash_find(hto, "uri", sizeof("uri"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING) {
uri = Z_STRVAL_PP(tmp);
}
}
if (headers == NULL || Z_TYPE_P(headers) == IS_NULL) {
} else if (Z_TYPE_P(headers) == IS_ARRAY) {
soap_headers = Z_ARRVAL_P(headers);
verify_soap_headers_array(soap_headers TSRMLS_CC);
free_soap_headers = 0;
} else if (Z_TYPE_P(headers) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(headers), soap_header_class_entry TSRMLS_CC)) {
soap_headers = emalloc(sizeof(HashTable));
zend_hash_init(soap_headers, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_next_index_insert(soap_headers, &headers, sizeof(zval*), NULL);
Z_ADDREF_P(headers);
free_soap_headers = 1;
} else{
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid SOAP header");
return;
}
/* Add default headers */
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__default_headers", sizeof("__default_headers"), (void **) &tmp)==SUCCESS &&
Z_TYPE_PP(tmp) == IS_ARRAY) {
HashTable *default_headers = Z_ARRVAL_P(*tmp);
if (soap_headers) {
if (!free_soap_headers) {
HashTable *t = emalloc(sizeof(HashTable));
zend_hash_init(t, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_copy(t, soap_headers, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
soap_headers = t;
free_soap_headers = 1;
}
zend_hash_internal_pointer_reset(default_headers);
while (zend_hash_get_current_data(default_headers, (void**)&tmp) == SUCCESS) {
Z_ADDREF_PP(tmp);
zend_hash_next_index_insert(soap_headers, tmp, sizeof(zval *), NULL);
zend_hash_move_forward(default_headers);
}
} else {
soap_headers = Z_ARRVAL_P(*tmp);
free_soap_headers = 0;
}
}
arg_count = zend_hash_num_elements(Z_ARRVAL_P(args));
if (arg_count > 0) {
real_args = safe_emalloc(sizeof(zval *), arg_count, 0);
for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(args), &pos);
zend_hash_get_current_data_ex(Z_ARRVAL_P(args), (void **) ¶m, &pos) == SUCCESS;
zend_hash_move_forward_ex(Z_ARRVAL_P(args), &pos)) {
/*zval_add_ref(param);*/
real_args[i++] = *param;
}
}
if (output_headers) {
array_init(output_headers);
}
do_soap_call(this_ptr, function, function_len, arg_count, real_args, return_value, location, soap_action, uri, soap_headers, output_headers TSRMLS_CC);
if (arg_count > 0) {
efree(real_args);
}
if (soap_headers && free_soap_headers) {
zend_hash_destroy(soap_headers);
efree(soap_headers);
}
}
| @@ -2554,7 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -2594,7 +2594,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
ret = FALSE;
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
}
xmlFree(buf);
@@ -2633,13 +2633,13 @@ static void do_soap_call(zval* this_ptr,
SOAP_CLIENT_BEGIN_CODE();
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
- && Z_LVAL_PP(tmp) == SOAP_1_2) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
@@ -2735,7 +2735,7 @@ static void do_soap_call(zval* this_ptr,
zval **uri;
smart_str action = {0};
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3006,7 +3006,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3024,7 +3025,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3042,7 +3044,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3060,7 +3063,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3116,13 +3120,15 @@ PHP_METHOD(SoapClient, __setCookie)
}
if (val == NULL) {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
}
} else {
zval *zcookie;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
@@ -3150,7 +3156,8 @@ PHP_METHOD(SoapClient, __getCookies)
array_init(return_value);
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
}
}
@@ -4237,7 +4244,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
}
} else {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
+ Z_TYPE_PP(zstyle) == IS_LONG) {
style = Z_LVAL_PP(zstyle);
} else {
style = SOAP_RPC;
@@ -4260,7 +4268,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
- Z_LVAL_PP(zuse) == SOAP_LITERAL) {
+ Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
@@ -4390,6 +4398,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
zval **param_data;
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS &&
+ Z_TYPE_PP(param_name) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name); | null | null | null |
11,938 | PHP_METHOD(SoapClient, __getFunctions)
{
sdlPtr sdl;
HashPosition pos;
FETCH_THIS_SDL(sdl);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (sdl) {
smart_str buf = {0};
sdlFunctionPtr *function;
array_init(return_value);
zend_hash_internal_pointer_reset_ex(&sdl->functions, &pos);
while (zend_hash_get_current_data_ex(&sdl->functions, (void **)&function, &pos) != FAILURE) {
function_to_string((*function), &buf);
add_next_index_stringl(return_value, buf.c, buf.len, 1);
smart_str_free(&buf);
zend_hash_move_forward_ex(&sdl->functions, &pos);
}
}
}
| DoS Exec Code | 0 | PHP_METHOD(SoapClient, __getFunctions)
{
sdlPtr sdl;
HashPosition pos;
FETCH_THIS_SDL(sdl);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (sdl) {
smart_str buf = {0};
sdlFunctionPtr *function;
array_init(return_value);
zend_hash_internal_pointer_reset_ex(&sdl->functions, &pos);
while (zend_hash_get_current_data_ex(&sdl->functions, (void **)&function, &pos) != FAILURE) {
function_to_string((*function), &buf);
add_next_index_stringl(return_value, buf.c, buf.len, 1);
smart_str_free(&buf);
zend_hash_move_forward_ex(&sdl->functions, &pos);
}
}
}
| @@ -2554,7 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -2594,7 +2594,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
ret = FALSE;
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
}
xmlFree(buf);
@@ -2633,13 +2633,13 @@ static void do_soap_call(zval* this_ptr,
SOAP_CLIENT_BEGIN_CODE();
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
- && Z_LVAL_PP(tmp) == SOAP_1_2) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
@@ -2735,7 +2735,7 @@ static void do_soap_call(zval* this_ptr,
zval **uri;
smart_str action = {0};
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3006,7 +3006,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3024,7 +3025,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3042,7 +3044,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3060,7 +3063,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3116,13 +3120,15 @@ PHP_METHOD(SoapClient, __setCookie)
}
if (val == NULL) {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
}
} else {
zval *zcookie;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
@@ -3150,7 +3156,8 @@ PHP_METHOD(SoapClient, __getCookies)
array_init(return_value);
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
}
}
@@ -4237,7 +4244,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
}
} else {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
+ Z_TYPE_PP(zstyle) == IS_LONG) {
style = Z_LVAL_PP(zstyle);
} else {
style = SOAP_RPC;
@@ -4260,7 +4268,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
- Z_LVAL_PP(zuse) == SOAP_LITERAL) {
+ Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
@@ -4390,6 +4398,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
zval **param_data;
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS &&
+ Z_TYPE_PP(param_name) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name); | null | null | null |
11,939 | PHP_METHOD(SoapClient, __getTypes)
{
sdlPtr sdl;
HashPosition pos;
FETCH_THIS_SDL(sdl);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (sdl) {
sdlTypePtr *type;
smart_str buf = {0};
array_init(return_value);
if (sdl->types) {
zend_hash_internal_pointer_reset_ex(sdl->types, &pos);
while (zend_hash_get_current_data_ex(sdl->types, (void **)&type, &pos) != FAILURE) {
type_to_string((*type), &buf, 0);
add_next_index_stringl(return_value, buf.c, buf.len, 1);
smart_str_free(&buf);
zend_hash_move_forward_ex(sdl->types, &pos);
}
}
}
}
| DoS Exec Code | 0 | PHP_METHOD(SoapClient, __getTypes)
{
sdlPtr sdl;
HashPosition pos;
FETCH_THIS_SDL(sdl);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (sdl) {
sdlTypePtr *type;
smart_str buf = {0};
array_init(return_value);
if (sdl->types) {
zend_hash_internal_pointer_reset_ex(sdl->types, &pos);
while (zend_hash_get_current_data_ex(sdl->types, (void **)&type, &pos) != FAILURE) {
type_to_string((*type), &buf, 0);
add_next_index_stringl(return_value, buf.c, buf.len, 1);
smart_str_free(&buf);
zend_hash_move_forward_ex(sdl->types, &pos);
}
}
}
}
| @@ -2554,7 +2554,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -2594,7 +2594,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
}
ret = FALSE;
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
- Z_LVAL_PP(trace) > 0) {
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
}
xmlFree(buf);
@@ -2633,13 +2633,13 @@ static void do_soap_call(zval* this_ptr,
SOAP_CLIENT_BEGIN_CODE();
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ (Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
- && Z_LVAL_PP(tmp) == SOAP_1_2) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
soap_version = SOAP_1_1;
@@ -2735,7 +2735,7 @@ static void do_soap_call(zval* this_ptr,
zval **uri;
smart_str action = {0};
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
} else if (location == NULL) {
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3006,7 +3006,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3024,7 +3025,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3042,7 +3044,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3060,7 +3063,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
return;
}
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_STRING) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -3116,13 +3120,15 @@ PHP_METHOD(SoapClient, __setCookie)
}
if (val == NULL) {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
}
} else {
zval *zcookie;
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
+ Z_TYPE_PP(cookies) != IS_ARRAY) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
@@ -3150,7 +3156,8 @@ PHP_METHOD(SoapClient, __getCookies)
array_init(return_value);
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
+ Z_TYPE_PP(cookies) == IS_ARRAY) {
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
}
}
@@ -4237,7 +4244,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
}
} else {
- if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
+ Z_TYPE_PP(zstyle) == IS_LONG) {
style = Z_LVAL_PP(zstyle);
} else {
style = SOAP_RPC;
@@ -4260,7 +4268,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
}
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
- Z_LVAL_PP(zuse) == SOAP_LITERAL) {
+ Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
use = SOAP_ENCODED;
@@ -4390,6 +4398,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
zval **param_data;
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS &&
+ Z_TYPE_PP(param_name) == IS_STRING &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name); | null | null | null |
11,940 | PHP_MINIT_FUNCTION(spl_heap) /* {{{ */
{
REGISTER_SPL_STD_CLASS_EX(SplHeap, spl_heap_object_new, spl_funcs_SplHeap);
memcpy(&spl_handler_SplHeap, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
spl_handler_SplHeap.clone_obj = spl_heap_object_clone;
spl_handler_SplHeap.count_elements = spl_heap_object_count_elements;
spl_handler_SplHeap.get_debug_info = spl_heap_object_get_debug_info;
REGISTER_SPL_IMPLEMENTS(SplHeap, Iterator);
REGISTER_SPL_IMPLEMENTS(SplHeap, Countable);
spl_ce_SplHeap->get_iterator = spl_heap_get_iterator;
REGISTER_SPL_SUB_CLASS_EX(SplMinHeap, SplHeap, spl_heap_object_new, spl_funcs_SplMinHeap);
REGISTER_SPL_SUB_CLASS_EX(SplMaxHeap, SplHeap, spl_heap_object_new, spl_funcs_SplMaxHeap);
spl_ce_SplMaxHeap->get_iterator = spl_heap_get_iterator;
spl_ce_SplMinHeap->get_iterator = spl_heap_get_iterator;
REGISTER_SPL_STD_CLASS_EX(SplPriorityQueue, spl_heap_object_new, spl_funcs_SplPriorityQueue);
memcpy(&spl_handler_SplPriorityQueue, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
spl_handler_SplPriorityQueue.clone_obj = spl_heap_object_clone;
spl_handler_SplPriorityQueue.count_elements = spl_heap_object_count_elements;
spl_handler_SplPriorityQueue.get_debug_info = spl_pqueue_object_get_debug_info;
REGISTER_SPL_IMPLEMENTS(SplPriorityQueue, Iterator);
REGISTER_SPL_IMPLEMENTS(SplPriorityQueue, Countable);
spl_ce_SplPriorityQueue->get_iterator = spl_pqueue_get_iterator;
REGISTER_SPL_CLASS_CONST_LONG(SplPriorityQueue, "EXTR_BOTH", SPL_PQUEUE_EXTR_BOTH);
REGISTER_SPL_CLASS_CONST_LONG(SplPriorityQueue, "EXTR_PRIORITY", SPL_PQUEUE_EXTR_PRIORITY);
REGISTER_SPL_CLASS_CONST_LONG(SplPriorityQueue, "EXTR_DATA", SPL_PQUEUE_EXTR_DATA);
return SUCCESS;
}
/* }}} */
| Exec Code | 0 | PHP_MINIT_FUNCTION(spl_heap) /* {{{ */
{
REGISTER_SPL_STD_CLASS_EX(SplHeap, spl_heap_object_new, spl_funcs_SplHeap);
memcpy(&spl_handler_SplHeap, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
spl_handler_SplHeap.clone_obj = spl_heap_object_clone;
spl_handler_SplHeap.count_elements = spl_heap_object_count_elements;
spl_handler_SplHeap.get_debug_info = spl_heap_object_get_debug_info;
REGISTER_SPL_IMPLEMENTS(SplHeap, Iterator);
REGISTER_SPL_IMPLEMENTS(SplHeap, Countable);
spl_ce_SplHeap->get_iterator = spl_heap_get_iterator;
REGISTER_SPL_SUB_CLASS_EX(SplMinHeap, SplHeap, spl_heap_object_new, spl_funcs_SplMinHeap);
REGISTER_SPL_SUB_CLASS_EX(SplMaxHeap, SplHeap, spl_heap_object_new, spl_funcs_SplMaxHeap);
spl_ce_SplMaxHeap->get_iterator = spl_heap_get_iterator;
spl_ce_SplMinHeap->get_iterator = spl_heap_get_iterator;
REGISTER_SPL_STD_CLASS_EX(SplPriorityQueue, spl_heap_object_new, spl_funcs_SplPriorityQueue);
memcpy(&spl_handler_SplPriorityQueue, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
spl_handler_SplPriorityQueue.clone_obj = spl_heap_object_clone;
spl_handler_SplPriorityQueue.count_elements = spl_heap_object_count_elements;
spl_handler_SplPriorityQueue.get_debug_info = spl_pqueue_object_get_debug_info;
REGISTER_SPL_IMPLEMENTS(SplPriorityQueue, Iterator);
REGISTER_SPL_IMPLEMENTS(SplPriorityQueue, Countable);
spl_ce_SplPriorityQueue->get_iterator = spl_pqueue_get_iterator;
REGISTER_SPL_CLASS_CONST_LONG(SplPriorityQueue, "EXTR_BOTH", SPL_PQUEUE_EXTR_BOTH);
REGISTER_SPL_CLASS_CONST_LONG(SplPriorityQueue, "EXTR_PRIORITY", SPL_PQUEUE_EXTR_PRIORITY);
REGISTER_SPL_CLASS_CONST_LONG(SplPriorityQueue, "EXTR_DATA", SPL_PQUEUE_EXTR_DATA);
return SUCCESS;
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,941 | SPL_METHOD(SplHeap, count)
{
long count;
spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
count = spl_ptr_heap_count(intern->heap);
RETURN_LONG(count);
}
| Exec Code | 0 | SPL_METHOD(SplHeap, count)
{
long count;
spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
count = spl_ptr_heap_count(intern->heap);
RETURN_LONG(count);
}
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,942 | SPL_METHOD(SplHeap, insert)
{
zval *value;
spl_heap_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
return;
}
intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (intern->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0 TSRMLS_CC);
return;
}
SEPARATE_ARG_IF_REF(value);
spl_ptr_heap_insert(intern->heap, value, getThis() TSRMLS_CC);
RETURN_TRUE;
}
| Exec Code | 0 | SPL_METHOD(SplHeap, insert)
{
zval *value;
spl_heap_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
return;
}
intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (intern->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0 TSRMLS_CC);
return;
}
SEPARATE_ARG_IF_REF(value);
spl_ptr_heap_insert(intern->heap, value, getThis() TSRMLS_CC);
RETURN_TRUE;
}
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,943 | SPL_METHOD(SplPriorityQueue, insert)
{
zval *data, *priority, *elem;
spl_heap_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &data, &priority) == FAILURE) {
return;
}
intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (intern->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0 TSRMLS_CC);
return;
}
SEPARATE_ARG_IF_REF(data);
SEPARATE_ARG_IF_REF(priority);
ALLOC_INIT_ZVAL(elem);
array_init(elem);
add_assoc_zval_ex(elem, "data", sizeof("data"), data);
add_assoc_zval_ex(elem, "priority", sizeof("priority"), priority);
spl_ptr_heap_insert(intern->heap, elem, getThis() TSRMLS_CC);
RETURN_TRUE;
}
| Exec Code | 0 | SPL_METHOD(SplPriorityQueue, insert)
{
zval *data, *priority, *elem;
spl_heap_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &data, &priority) == FAILURE) {
return;
}
intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (intern->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0 TSRMLS_CC);
return;
}
SEPARATE_ARG_IF_REF(data);
SEPARATE_ARG_IF_REF(priority);
ALLOC_INIT_ZVAL(elem);
array_init(elem);
add_assoc_zval_ex(elem, "data", sizeof("data"), data);
add_assoc_zval_ex(elem, "priority", sizeof("priority"), priority);
spl_ptr_heap_insert(intern->heap, elem, getThis() TSRMLS_CC);
RETURN_TRUE;
}
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,944 | SPL_METHOD(SplPriorityQueue, extract)
{
zval *value, *value_out, **value_out_pp;
spl_heap_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (intern->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0 TSRMLS_CC);
return;
}
value = (zval *)spl_ptr_heap_delete_top(intern->heap, getThis() TSRMLS_CC);
if (!value) {
zend_throw_exception(spl_ce_RuntimeException, "Can't extract from an empty heap", 0 TSRMLS_CC);
return;
}
value_out_pp = spl_pqueue_extract_helper(&value, intern->flags);
if (!value_out_pp) {
zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
zval_ptr_dtor(&value);
return;
}
value_out = *value_out_pp;
Z_ADDREF_P(value_out);
zval_ptr_dtor(&value);
RETURN_ZVAL(value_out, 1, 1);
}
| Exec Code | 0 | SPL_METHOD(SplPriorityQueue, extract)
{
zval *value, *value_out, **value_out_pp;
spl_heap_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (intern->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0 TSRMLS_CC);
return;
}
value = (zval *)spl_ptr_heap_delete_top(intern->heap, getThis() TSRMLS_CC);
if (!value) {
zend_throw_exception(spl_ce_RuntimeException, "Can't extract from an empty heap", 0 TSRMLS_CC);
return;
}
value_out_pp = spl_pqueue_extract_helper(&value, intern->flags);
if (!value_out_pp) {
zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
zval_ptr_dtor(&value);
return;
}
value_out = *value_out_pp;
Z_ADDREF_P(value_out);
zval_ptr_dtor(&value);
RETURN_ZVAL(value_out, 1, 1);
}
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,945 | SPL_METHOD(SplPriorityQueue, top)
{
zval *value, **value_out;
spl_heap_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (intern->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0 TSRMLS_CC);
return;
}
value = (zval *)spl_ptr_heap_top(intern->heap);
if (!value) {
zend_throw_exception(spl_ce_RuntimeException, "Can't peek at an empty heap", 0 TSRMLS_CC);
return;
}
value_out = spl_pqueue_extract_helper(&value, intern->flags);
if (!value_out) {
zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
return;
}
RETURN_ZVAL(*value_out, 1, 0);
}
| Exec Code | 0 | SPL_METHOD(SplPriorityQueue, top)
{
zval *value, **value_out;
spl_heap_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (intern->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0 TSRMLS_CC);
return;
}
value = (zval *)spl_ptr_heap_top(intern->heap);
if (!value) {
zend_throw_exception(spl_ce_RuntimeException, "Can't peek at an empty heap", 0 TSRMLS_CC);
return;
}
value_out = spl_pqueue_extract_helper(&value, intern->flags);
if (!value_out) {
zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
return;
}
RETURN_ZVAL(*value_out, 1, 0);
}
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,946 | SPL_METHOD(SplPriorityQueue, setExtractFlags)
{
long value;
spl_heap_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) == FAILURE) {
return;
}
intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
intern->flags = value & SPL_PQUEUE_EXTR_MASK;
RETURN_LONG(intern->flags);
}
| Exec Code | 0 | SPL_METHOD(SplPriorityQueue, setExtractFlags)
{
long value;
spl_heap_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) == FAILURE) {
return;
}
intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
intern->flags = value & SPL_PQUEUE_EXTR_MASK;
RETURN_LONG(intern->flags);
}
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,947 | SPL_METHOD(SplHeap, recoverFromCorruption)
{
spl_heap_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
intern->heap->flags = intern->heap->flags & ~SPL_HEAP_CORRUPTED;
RETURN_TRUE;
}
| Exec Code | 0 | SPL_METHOD(SplHeap, recoverFromCorruption)
{
spl_heap_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
intern->heap->flags = intern->heap->flags & ~SPL_HEAP_CORRUPTED;
RETURN_TRUE;
}
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,948 | SPL_METHOD(SplPriorityQueue, compare)
{
zval *a, *b;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &a, &b) == FAILURE) {
return;
}
RETURN_LONG(spl_ptr_heap_zval_max_cmp(a, b, NULL TSRMLS_CC));
}
| Exec Code | 0 | SPL_METHOD(SplPriorityQueue, compare)
{
zval *a, *b;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &a, &b) == FAILURE) {
return;
}
RETURN_LONG(spl_ptr_heap_zval_max_cmp(a, b, NULL TSRMLS_CC));
}
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,949 | SPL_METHOD(SplHeap, top)
{
zval *value;
spl_heap_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (intern->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0 TSRMLS_CC);
return;
}
value = (zval *)spl_ptr_heap_top(intern->heap);
if (!value) {
zend_throw_exception(spl_ce_RuntimeException, "Can't peek at an empty heap", 0 TSRMLS_CC);
return;
}
RETURN_ZVAL(value, 1, 0);
}
| Exec Code | 0 | SPL_METHOD(SplHeap, top)
{
zval *value;
spl_heap_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (intern->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0 TSRMLS_CC);
return;
}
value = (zval *)spl_ptr_heap_top(intern->heap);
if (!value) {
zend_throw_exception(spl_ce_RuntimeException, "Can't peek at an empty heap", 0 TSRMLS_CC);
return;
}
RETURN_ZVAL(value, 1, 0);
}
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,950 | SPL_METHOD(SplMinHeap, compare)
{
zval *a, *b;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &a, &b) == FAILURE) {
return;
}
RETURN_LONG(spl_ptr_heap_zval_min_cmp(a, b, NULL TSRMLS_CC));
}
| Exec Code | 0 | SPL_METHOD(SplMinHeap, compare)
{
zval *a, *b;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &a, &b) == FAILURE) {
return;
}
RETURN_LONG(spl_ptr_heap_zval_min_cmp(a, b, NULL TSRMLS_CC));
}
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,951 | SPL_METHOD(SplMaxHeap, compare)
{
zval *a, *b;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &a, &b) == FAILURE) {
return;
}
RETURN_LONG(spl_ptr_heap_zval_max_cmp(a, b, NULL TSRMLS_CC));
}
| Exec Code | 0 | SPL_METHOD(SplMaxHeap, compare)
{
zval *a, *b;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &a, &b) == FAILURE) {
return;
}
RETURN_LONG(spl_ptr_heap_zval_max_cmp(a, b, NULL TSRMLS_CC));
}
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,952 | SPL_METHOD(SplHeap, key)
{
spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(intern->heap->count - 1);
}
| Exec Code | 0 | SPL_METHOD(SplHeap, key)
{
spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(intern->heap->count - 1);
}
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,953 | SPL_METHOD(SplHeap, next)
{
spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
spl_ptr_heap_element elem = spl_ptr_heap_delete_top(intern->heap, getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (elem != NULL) {
zval_ptr_dtor((zval **)&elem);
}
}
| Exec Code | 0 | SPL_METHOD(SplHeap, next)
{
spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
spl_ptr_heap_element elem = spl_ptr_heap_delete_top(intern->heap, getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (elem != NULL) {
zval_ptr_dtor((zval **)&elem);
}
}
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,954 | SPL_METHOD(SplHeap, valid)
{
spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_BOOL(intern->heap->count != 0);
}
| Exec Code | 0 | SPL_METHOD(SplHeap, valid)
{
spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_BOOL(intern->heap->count != 0);
}
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,955 | SPL_METHOD(SplHeap, rewind)
{
if (zend_parse_parameters_none() == FAILURE) {
return;
}
/* do nothing, the iterator always points to the top element */
}
| Exec Code | 0 | SPL_METHOD(SplHeap, rewind)
{
if (zend_parse_parameters_none() == FAILURE) {
return;
}
/* do nothing, the iterator always points to the top element */
}
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,956 | SPL_METHOD(SplPriorityQueue, current)
{
spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
zval **element = (zval **)&intern->heap->elements[0];
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (!intern->heap->count || !*element) {
RETURN_NULL();
} else {
zval **data = spl_pqueue_extract_helper(element, intern->flags);
if (!data) {
zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
RETURN_NULL();
}
RETURN_ZVAL(*data, 1, 0);
}
}
| Exec Code | 0 | SPL_METHOD(SplPriorityQueue, current)
{
spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
zval **element = (zval **)&intern->heap->elements[0];
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (!intern->heap->count || !*element) {
RETURN_NULL();
} else {
zval **data = spl_pqueue_extract_helper(element, intern->flags);
if (!data) {
zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
RETURN_NULL();
}
RETURN_ZVAL(*data, 1, 0);
}
}
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,957 | zend_object_iterator *spl_heap_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC) /* {{{ */
{
spl_heap_it *iterator;
spl_heap_object *heap_object = (spl_heap_object*)zend_object_store_get_object(object TSRMLS_CC);
if (by_ref) {
zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0 TSRMLS_CC);
return NULL;
}
Z_ADDREF_P(object);
iterator = emalloc(sizeof(spl_heap_it));
iterator->intern.it.data = (void*)object;
iterator->intern.it.funcs = &spl_heap_it_funcs;
iterator->intern.ce = ce;
iterator->intern.value = NULL;
iterator->flags = heap_object->flags;
iterator->object = heap_object;
return (zend_object_iterator*)iterator;
}
/* }}} */
| Exec Code | 0 | zend_object_iterator *spl_heap_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC) /* {{{ */
{
spl_heap_it *iterator;
spl_heap_object *heap_object = (spl_heap_object*)zend_object_store_get_object(object TSRMLS_CC);
if (by_ref) {
zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0 TSRMLS_CC);
return NULL;
}
Z_ADDREF_P(object);
iterator = emalloc(sizeof(spl_heap_it));
iterator->intern.it.data = (void*)object;
iterator->intern.it.funcs = &spl_heap_it_funcs;
iterator->intern.ce = ce;
iterator->intern.value = NULL;
iterator->flags = heap_object->flags;
iterator->object = heap_object;
return (zend_object_iterator*)iterator;
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,958 | static void spl_heap_it_dtor(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
{
spl_heap_it *iterator = (spl_heap_it *)iter;
zend_user_it_invalidate_current(iter TSRMLS_CC);
zval_ptr_dtor((zval**)&iterator->intern.it.data);
efree(iterator);
}
/* }}} */
| Exec Code | 0 | static void spl_heap_it_dtor(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
{
spl_heap_it *iterator = (spl_heap_it *)iter;
zend_user_it_invalidate_current(iter TSRMLS_CC);
zval_ptr_dtor((zval**)&iterator->intern.it.data);
efree(iterator);
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,959 | static void spl_heap_it_get_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC) /* {{{ */
{
spl_heap_it *iterator = (spl_heap_it *)iter;
zval **element = (zval **)&iterator->object->heap->elements[0];
if (iterator->object->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0 TSRMLS_CC);
return;
}
if (iterator->object->heap->count == 0 || !*element) {
*data = NULL;
} else {
*data = element;
}
}
/* }}} */
| Exec Code | 0 | static void spl_heap_it_get_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC) /* {{{ */
{
spl_heap_it *iterator = (spl_heap_it *)iter;
zval **element = (zval **)&iterator->object->heap->elements[0];
if (iterator->object->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0 TSRMLS_CC);
return;
}
if (iterator->object->heap->count == 0 || !*element) {
*data = NULL;
} else {
*data = element;
}
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,960 | static void spl_heap_it_get_current_key(zend_object_iterator *iter, zval *key TSRMLS_DC) /* {{{ */
{
spl_heap_it *iterator = (spl_heap_it *)iter;
ZVAL_LONG(key, iterator->object->heap->count - 1);
}
/* }}} */
| Exec Code | 0 | static void spl_heap_it_get_current_key(zend_object_iterator *iter, zval *key TSRMLS_DC) /* {{{ */
{
spl_heap_it *iterator = (spl_heap_it *)iter;
ZVAL_LONG(key, iterator->object->heap->count - 1);
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,961 | static void spl_heap_it_move_forward(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
{
zval *object = (zval*)((zend_user_iterator *)iter)->it.data;
spl_heap_it *iterator = (spl_heap_it *)iter;
spl_ptr_heap_element elem;
if (iterator->object->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0 TSRMLS_CC);
return;
}
elem = spl_ptr_heap_delete_top(iterator->object->heap, object TSRMLS_CC);
if (elem != NULL) {
zval_ptr_dtor((zval **)&elem);
}
zend_user_it_invalidate_current(iter TSRMLS_CC);
}
/* }}} */
| Exec Code | 0 | static void spl_heap_it_move_forward(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
{
zval *object = (zval*)((zend_user_iterator *)iter)->it.data;
spl_heap_it *iterator = (spl_heap_it *)iter;
spl_ptr_heap_element elem;
if (iterator->object->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0 TSRMLS_CC);
return;
}
elem = spl_ptr_heap_delete_top(iterator->object->heap, object TSRMLS_CC);
if (elem != NULL) {
zval_ptr_dtor((zval **)&elem);
}
zend_user_it_invalidate_current(iter TSRMLS_CC);
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,962 | static void spl_heap_it_rewind(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
{
/* do nothing, the iterator always points to the top element */
}
/* }}} */
| Exec Code | 0 | static void spl_heap_it_rewind(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
{
/* do nothing, the iterator always points to the top element */
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,963 | static int spl_heap_it_valid(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
{
spl_heap_it *iterator = (spl_heap_it *)iter;
return (iterator->object->heap->count != 0 ? SUCCESS : FAILURE);
}
/* }}} */
| Exec Code | 0 | static int spl_heap_it_valid(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
{
spl_heap_it *iterator = (spl_heap_it *)iter;
return (iterator->object->heap->count != 0 ? SUCCESS : FAILURE);
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,964 | static void spl_heap_object_free_storage(void *object TSRMLS_DC) /* {{{ */
{
int i;
spl_heap_object *intern = (spl_heap_object *)object;
zend_object_std_dtor(&intern->std TSRMLS_CC);
for (i = 0; i < intern->heap->count; ++i) {
if (intern->heap->elements[i]) {
zval_ptr_dtor((zval **)&intern->heap->elements[i]);
}
}
spl_ptr_heap_destroy(intern->heap TSRMLS_CC);
zval_ptr_dtor(&intern->retval);
if (intern->debug_info != NULL) {
zend_hash_destroy(intern->debug_info);
efree(intern->debug_info);
}
efree(object);
}
/* }}} */
| Exec Code | 0 | static void spl_heap_object_free_storage(void *object TSRMLS_DC) /* {{{ */
{
int i;
spl_heap_object *intern = (spl_heap_object *)object;
zend_object_std_dtor(&intern->std TSRMLS_CC);
for (i = 0; i < intern->heap->count; ++i) {
if (intern->heap->elements[i]) {
zval_ptr_dtor((zval **)&intern->heap->elements[i]);
}
}
spl_ptr_heap_destroy(intern->heap TSRMLS_CC);
zval_ptr_dtor(&intern->retval);
if (intern->debug_info != NULL) {
zend_hash_destroy(intern->debug_info);
efree(intern->debug_info);
}
efree(object);
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,965 | static HashTable* spl_heap_object_get_debug_info_helper(zend_class_entry *ce, zval *obj, int *is_temp TSRMLS_DC) { /* {{{ */
spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(obj TSRMLS_CC);
zval *tmp, zrv, *heap_array;
char *pnstr;
int pnlen;
int i;
*is_temp = 0;
if (!intern->std.properties) {
rebuild_object_properties(&intern->std);
}
if (intern->debug_info == NULL) {
ALLOC_HASHTABLE(intern->debug_info);
ZEND_INIT_SYMTABLE_EX(intern->debug_info, zend_hash_num_elements(intern->std.properties) + 1, 0);
}
if (intern->debug_info->nApplyCount == 0) {
INIT_PZVAL(&zrv);
Z_ARRVAL(zrv) = intern->debug_info;
zend_hash_copy(intern->debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
pnstr = spl_gen_private_prop_name(ce, "flags", sizeof("flags")-1, &pnlen TSRMLS_CC);
add_assoc_long_ex(&zrv, pnstr, pnlen+1, intern->flags);
efree(pnstr);
pnstr = spl_gen_private_prop_name(ce, "isCorrupted", sizeof("isCorrupted")-1, &pnlen TSRMLS_CC);
add_assoc_bool_ex(&zrv, pnstr, pnlen+1, intern->heap->flags&SPL_HEAP_CORRUPTED);
efree(pnstr);
ALLOC_INIT_ZVAL(heap_array);
array_init(heap_array);
for (i = 0; i < intern->heap->count; ++i) {
add_index_zval(heap_array, i, (zval *)intern->heap->elements[i]);
Z_ADDREF_P(intern->heap->elements[i]);
}
pnstr = spl_gen_private_prop_name(ce, "heap", sizeof("heap")-1, &pnlen TSRMLS_CC);
add_assoc_zval_ex(&zrv, pnstr, pnlen+1, heap_array);
efree(pnstr);
}
return intern->debug_info;
}
/* }}} */
| Exec Code | 0 | static HashTable* spl_heap_object_get_debug_info_helper(zend_class_entry *ce, zval *obj, int *is_temp TSRMLS_DC) { /* {{{ */
spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(obj TSRMLS_CC);
zval *tmp, zrv, *heap_array;
char *pnstr;
int pnlen;
int i;
*is_temp = 0;
if (!intern->std.properties) {
rebuild_object_properties(&intern->std);
}
if (intern->debug_info == NULL) {
ALLOC_HASHTABLE(intern->debug_info);
ZEND_INIT_SYMTABLE_EX(intern->debug_info, zend_hash_num_elements(intern->std.properties) + 1, 0);
}
if (intern->debug_info->nApplyCount == 0) {
INIT_PZVAL(&zrv);
Z_ARRVAL(zrv) = intern->debug_info;
zend_hash_copy(intern->debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
pnstr = spl_gen_private_prop_name(ce, "flags", sizeof("flags")-1, &pnlen TSRMLS_CC);
add_assoc_long_ex(&zrv, pnstr, pnlen+1, intern->flags);
efree(pnstr);
pnstr = spl_gen_private_prop_name(ce, "isCorrupted", sizeof("isCorrupted")-1, &pnlen TSRMLS_CC);
add_assoc_bool_ex(&zrv, pnstr, pnlen+1, intern->heap->flags&SPL_HEAP_CORRUPTED);
efree(pnstr);
ALLOC_INIT_ZVAL(heap_array);
array_init(heap_array);
for (i = 0; i < intern->heap->count; ++i) {
add_index_zval(heap_array, i, (zval *)intern->heap->elements[i]);
Z_ADDREF_P(intern->heap->elements[i]);
}
pnstr = spl_gen_private_prop_name(ce, "heap", sizeof("heap")-1, &pnlen TSRMLS_CC);
add_assoc_zval_ex(&zrv, pnstr, pnlen+1, heap_array);
efree(pnstr);
}
return intern->debug_info;
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,966 | static zend_object_value spl_heap_object_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
spl_heap_object *tmp;
return spl_heap_object_new_ex(class_type, &tmp, NULL, 0 TSRMLS_CC);
}
/* }}} */
| Exec Code | 0 | static zend_object_value spl_heap_object_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
spl_heap_object *tmp;
return spl_heap_object_new_ex(class_type, &tmp, NULL, 0 TSRMLS_CC);
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,967 | static zend_object_value spl_heap_object_new_ex(zend_class_entry *class_type, spl_heap_object **obj, zval *orig, int clone_orig TSRMLS_DC) /* {{{ */
{
zend_object_value retval;
spl_heap_object *intern;
zend_class_entry *parent = class_type;
int inherited = 0;
intern = ecalloc(1, sizeof(spl_heap_object));
*obj = intern;
ALLOC_INIT_ZVAL(intern->retval);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
intern->flags = 0;
intern->fptr_cmp = NULL;
intern->debug_info = NULL;
if (orig) {
spl_heap_object *other = (spl_heap_object*)zend_object_store_get_object(orig TSRMLS_CC);
intern->ce_get_iterator = other->ce_get_iterator;
if (clone_orig) {
int i;
intern->heap = spl_ptr_heap_clone(other->heap TSRMLS_CC);
for (i = 0; i < intern->heap->count; ++i) {
if (intern->heap->elements[i]) {
Z_ADDREF_P((zval *)intern->heap->elements[i]);
}
}
} else {
intern->heap = other->heap;
}
intern->flags = other->flags;
} else {
intern->heap = spl_ptr_heap_init(spl_ptr_heap_zval_max_cmp, spl_ptr_heap_zval_ctor, spl_ptr_heap_zval_dtor);
}
retval.handlers = &spl_handler_SplHeap;
while (parent) {
if (parent == spl_ce_SplPriorityQueue) {
intern->heap->cmp = spl_ptr_pqueue_zval_cmp;
intern->flags = SPL_PQUEUE_EXTR_DATA;
retval.handlers = &spl_handler_SplPriorityQueue;
break;
}
if (parent == spl_ce_SplMinHeap) {
intern->heap->cmp = spl_ptr_heap_zval_min_cmp;
break;
}
if (parent == spl_ce_SplMaxHeap) {
intern->heap->cmp = spl_ptr_heap_zval_max_cmp;
break;
}
if (parent == spl_ce_SplHeap) {
break;
}
parent = parent->parent;
inherited = 1;
}
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, spl_heap_object_free_storage, NULL TSRMLS_CC);
if (!parent) { /* this must never happen */
php_error_docref(NULL TSRMLS_CC, E_COMPILE_ERROR, "Internal compiler error, Class is not child of SplHeap");
}
if (inherited) {
zend_hash_find(&class_type->function_table, "compare", sizeof("compare"), (void **) &intern->fptr_cmp);
if (intern->fptr_cmp->common.scope == parent) {
intern->fptr_cmp = NULL;
}
zend_hash_find(&class_type->function_table, "count", sizeof("count"), (void **) &intern->fptr_count);
if (intern->fptr_count->common.scope == parent) {
intern->fptr_count = NULL;
}
}
return retval;
}
/* }}} */
| Exec Code | 0 | static zend_object_value spl_heap_object_new_ex(zend_class_entry *class_type, spl_heap_object **obj, zval *orig, int clone_orig TSRMLS_DC) /* {{{ */
{
zend_object_value retval;
spl_heap_object *intern;
zend_class_entry *parent = class_type;
int inherited = 0;
intern = ecalloc(1, sizeof(spl_heap_object));
*obj = intern;
ALLOC_INIT_ZVAL(intern->retval);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
intern->flags = 0;
intern->fptr_cmp = NULL;
intern->debug_info = NULL;
if (orig) {
spl_heap_object *other = (spl_heap_object*)zend_object_store_get_object(orig TSRMLS_CC);
intern->ce_get_iterator = other->ce_get_iterator;
if (clone_orig) {
int i;
intern->heap = spl_ptr_heap_clone(other->heap TSRMLS_CC);
for (i = 0; i < intern->heap->count; ++i) {
if (intern->heap->elements[i]) {
Z_ADDREF_P((zval *)intern->heap->elements[i]);
}
}
} else {
intern->heap = other->heap;
}
intern->flags = other->flags;
} else {
intern->heap = spl_ptr_heap_init(spl_ptr_heap_zval_max_cmp, spl_ptr_heap_zval_ctor, spl_ptr_heap_zval_dtor);
}
retval.handlers = &spl_handler_SplHeap;
while (parent) {
if (parent == spl_ce_SplPriorityQueue) {
intern->heap->cmp = spl_ptr_pqueue_zval_cmp;
intern->flags = SPL_PQUEUE_EXTR_DATA;
retval.handlers = &spl_handler_SplPriorityQueue;
break;
}
if (parent == spl_ce_SplMinHeap) {
intern->heap->cmp = spl_ptr_heap_zval_min_cmp;
break;
}
if (parent == spl_ce_SplMaxHeap) {
intern->heap->cmp = spl_ptr_heap_zval_max_cmp;
break;
}
if (parent == spl_ce_SplHeap) {
break;
}
parent = parent->parent;
inherited = 1;
}
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, spl_heap_object_free_storage, NULL TSRMLS_CC);
if (!parent) { /* this must never happen */
php_error_docref(NULL TSRMLS_CC, E_COMPILE_ERROR, "Internal compiler error, Class is not child of SplHeap");
}
if (inherited) {
zend_hash_find(&class_type->function_table, "compare", sizeof("compare"), (void **) &intern->fptr_cmp);
if (intern->fptr_cmp->common.scope == parent) {
intern->fptr_cmp = NULL;
}
zend_hash_find(&class_type->function_table, "count", sizeof("count"), (void **) &intern->fptr_count);
if (intern->fptr_count->common.scope == parent) {
intern->fptr_count = NULL;
}
}
return retval;
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,968 | zend_object_iterator *spl_pqueue_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC) /* {{{ */
{
spl_heap_it *iterator;
spl_heap_object *heap_object = (spl_heap_object*)zend_object_store_get_object(object TSRMLS_CC);
if (by_ref) {
zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0 TSRMLS_CC);
return NULL;
}
Z_ADDREF_P(object);
iterator = emalloc(sizeof(spl_heap_it));
iterator->intern.it.data = (void*)object;
iterator->intern.it.funcs = &spl_pqueue_it_funcs;
iterator->intern.ce = ce;
iterator->intern.value = NULL;
iterator->flags = heap_object->flags;
iterator->object = heap_object;
return (zend_object_iterator*)iterator;
}
/* }}} */
| Exec Code | 0 | zend_object_iterator *spl_pqueue_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC) /* {{{ */
{
spl_heap_it *iterator;
spl_heap_object *heap_object = (spl_heap_object*)zend_object_store_get_object(object TSRMLS_CC);
if (by_ref) {
zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0 TSRMLS_CC);
return NULL;
}
Z_ADDREF_P(object);
iterator = emalloc(sizeof(spl_heap_it));
iterator->intern.it.data = (void*)object;
iterator->intern.it.funcs = &spl_pqueue_it_funcs;
iterator->intern.ce = ce;
iterator->intern.value = NULL;
iterator->flags = heap_object->flags;
iterator->object = heap_object;
return (zend_object_iterator*)iterator;
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,969 | static void spl_pqueue_it_get_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC) /* {{{ */
{
spl_heap_it *iterator = (spl_heap_it *)iter;
zval **element = (zval **)&iterator->object->heap->elements[0];
if (iterator->object->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0 TSRMLS_CC);
return;
}
if (iterator->object->heap->count == 0 || !*element) {
*data = NULL;
} else {
*data = spl_pqueue_extract_helper(element, iterator->object->flags);
if (!*data) {
zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
}
}
}
/* }}} */
| Exec Code | 0 | static void spl_pqueue_it_get_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC) /* {{{ */
{
spl_heap_it *iterator = (spl_heap_it *)iter;
zval **element = (zval **)&iterator->object->heap->elements[0];
if (iterator->object->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0 TSRMLS_CC);
return;
}
if (iterator->object->heap->count == 0 || !*element) {
*data = NULL;
} else {
*data = spl_pqueue_extract_helper(element, iterator->object->flags);
if (!*data) {
zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
}
}
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,970 | static HashTable* spl_pqueue_object_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) /* {{{ */
{
return spl_heap_object_get_debug_info_helper(spl_ce_SplPriorityQueue, obj, is_temp TSRMLS_CC);
}
/* }}} */
| Exec Code | 0 | static HashTable* spl_pqueue_object_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) /* {{{ */
{
return spl_heap_object_get_debug_info_helper(spl_ce_SplPriorityQueue, obj, is_temp TSRMLS_CC);
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,971 | static spl_ptr_heap *spl_ptr_heap_clone(spl_ptr_heap *from TSRMLS_DC) { /* {{{ */
int i;
spl_ptr_heap *heap = emalloc(sizeof(spl_ptr_heap));
heap->dtor = from->dtor;
heap->ctor = from->ctor;
heap->cmp = from->cmp;
heap->max_size = from->max_size;
heap->count = from->count;
heap->flags = from->flags;
heap->elements = safe_emalloc(sizeof(spl_ptr_heap_element),from->max_size,0);
memcpy(heap->elements, from->elements, sizeof(spl_ptr_heap_element)*from->max_size);
for (i=0; i < heap->count; ++i) {
heap->ctor(heap->elements[i] TSRMLS_CC);
}
return heap;
}
/* }}} */
| Exec Code | 0 | static spl_ptr_heap *spl_ptr_heap_clone(spl_ptr_heap *from TSRMLS_DC) { /* {{{ */
int i;
spl_ptr_heap *heap = emalloc(sizeof(spl_ptr_heap));
heap->dtor = from->dtor;
heap->ctor = from->ctor;
heap->cmp = from->cmp;
heap->max_size = from->max_size;
heap->count = from->count;
heap->flags = from->flags;
heap->elements = safe_emalloc(sizeof(spl_ptr_heap_element),from->max_size,0);
memcpy(heap->elements, from->elements, sizeof(spl_ptr_heap_element)*from->max_size);
for (i=0; i < heap->count; ++i) {
heap->ctor(heap->elements[i] TSRMLS_CC);
}
return heap;
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,972 | static int spl_ptr_heap_cmp_cb_helper(zval *object, spl_heap_object *heap_object, zval *a, zval *b, long *result TSRMLS_DC) { /* {{{ */
zval *result_p = NULL;
zend_call_method_with_2_params(&object, heap_object->std.ce, &heap_object->fptr_cmp, "compare", &result_p, a, b);
if (EG(exception)) {
return FAILURE;
}
convert_to_long(result_p);
*result = Z_LVAL_P(result_p);
zval_ptr_dtor(&result_p);
return SUCCESS;
}
/* }}} */
| Exec Code | 0 | static int spl_ptr_heap_cmp_cb_helper(zval *object, spl_heap_object *heap_object, zval *a, zval *b, long *result TSRMLS_DC) { /* {{{ */
zval *result_p = NULL;
zend_call_method_with_2_params(&object, heap_object->std.ce, &heap_object->fptr_cmp, "compare", &result_p, a, b);
if (EG(exception)) {
return FAILURE;
}
convert_to_long(result_p);
*result = Z_LVAL_P(result_p);
zval_ptr_dtor(&result_p);
return SUCCESS;
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,973 | static int spl_ptr_heap_count(spl_ptr_heap *heap) { /* {{{ */
return heap->count;
}
/* }}} */
| Exec Code | 0 | static int spl_ptr_heap_count(spl_ptr_heap *heap) { /* {{{ */
return heap->count;
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,974 | static spl_ptr_heap *spl_ptr_heap_init(spl_ptr_heap_cmp_func cmp, spl_ptr_heap_ctor_func ctor, spl_ptr_heap_dtor_func dtor) /* {{{ */
{
spl_ptr_heap *heap = emalloc(sizeof(spl_ptr_heap));
heap->dtor = dtor;
heap->ctor = ctor;
heap->cmp = cmp;
heap->elements = safe_emalloc(sizeof(spl_ptr_heap_element), PTR_HEAP_BLOCK_SIZE, 0);
heap->max_size = PTR_HEAP_BLOCK_SIZE;
heap->count = 0;
heap->flags = 0;
return heap;
}
/* }}} */
| Exec Code | 0 | static spl_ptr_heap *spl_ptr_heap_init(spl_ptr_heap_cmp_func cmp, spl_ptr_heap_ctor_func ctor, spl_ptr_heap_dtor_func dtor) /* {{{ */
{
spl_ptr_heap *heap = emalloc(sizeof(spl_ptr_heap));
heap->dtor = dtor;
heap->ctor = ctor;
heap->cmp = cmp;
heap->elements = safe_emalloc(sizeof(spl_ptr_heap_element), PTR_HEAP_BLOCK_SIZE, 0);
heap->max_size = PTR_HEAP_BLOCK_SIZE;
heap->count = 0;
heap->flags = 0;
return heap;
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,975 | static spl_ptr_heap_element spl_ptr_heap_top(spl_ptr_heap *heap) { /* {{{ */
if (heap->count == 0) {
return NULL;
}
return heap->elements[0];
}
/* }}} */
| Exec Code | 0 | static spl_ptr_heap_element spl_ptr_heap_top(spl_ptr_heap *heap) { /* {{{ */
if (heap->count == 0) {
return NULL;
}
return heap->elements[0];
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,976 | static void spl_ptr_heap_zval_ctor(spl_ptr_heap_element elem TSRMLS_DC) { /* {{{ */
Z_ADDREF_P((zval *)elem);
}
/* }}} */
| Exec Code | 0 | static void spl_ptr_heap_zval_ctor(spl_ptr_heap_element elem TSRMLS_DC) { /* {{{ */
Z_ADDREF_P((zval *)elem);
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,977 | static void spl_ptr_heap_zval_dtor(spl_ptr_heap_element elem TSRMLS_DC) { /* {{{ */
if (elem) {
zval_ptr_dtor((zval **)&elem);
}
}
/* }}} */
| Exec Code | 0 | static void spl_ptr_heap_zval_dtor(spl_ptr_heap_element elem TSRMLS_DC) { /* {{{ */
if (elem) {
zval_ptr_dtor((zval **)&elem);
}
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,978 | static int spl_ptr_heap_zval_max_cmp(spl_ptr_heap_element a, spl_ptr_heap_element b, void* object TSRMLS_DC) { /* {{{ */
zval result;
if (EG(exception)) {
return 0;
}
if (object) {
spl_heap_object *heap_object = (spl_heap_object*)zend_object_store_get_object((zval *)object TSRMLS_CC);
if (heap_object->fptr_cmp) {
long lval = 0;
if (spl_ptr_heap_cmp_cb_helper((zval *)object, heap_object, (zval *)a, (zval *)b, &lval TSRMLS_CC) == FAILURE) {
/* exception or call failure */
return 0;
}
return lval;
}
}
INIT_ZVAL(result);
compare_function(&result, (zval *)a, (zval *)b TSRMLS_CC);
return Z_LVAL(result);
}
/* }}} */
| Exec Code | 0 | static int spl_ptr_heap_zval_max_cmp(spl_ptr_heap_element a, spl_ptr_heap_element b, void* object TSRMLS_DC) { /* {{{ */
zval result;
if (EG(exception)) {
return 0;
}
if (object) {
spl_heap_object *heap_object = (spl_heap_object*)zend_object_store_get_object((zval *)object TSRMLS_CC);
if (heap_object->fptr_cmp) {
long lval = 0;
if (spl_ptr_heap_cmp_cb_helper((zval *)object, heap_object, (zval *)a, (zval *)b, &lval TSRMLS_CC) == FAILURE) {
/* exception or call failure */
return 0;
}
return lval;
}
}
INIT_ZVAL(result);
compare_function(&result, (zval *)a, (zval *)b TSRMLS_CC);
return Z_LVAL(result);
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,979 | static int spl_ptr_heap_zval_min_cmp(spl_ptr_heap_element a, spl_ptr_heap_element b, void* object TSRMLS_DC) { /* {{{ */
zval result;
if (EG(exception)) {
return 0;
}
if (object) {
spl_heap_object *heap_object = (spl_heap_object*)zend_object_store_get_object((zval *)object TSRMLS_CC);
if (heap_object->fptr_cmp) {
long lval = 0;
if (spl_ptr_heap_cmp_cb_helper((zval *)object, heap_object, (zval *)a, (zval *)b, &lval TSRMLS_CC) == FAILURE) {
/* exception or call failure */
return 0;
}
return lval;
}
}
INIT_ZVAL(result);
compare_function(&result, (zval *)b, (zval *)a TSRMLS_CC);
return Z_LVAL(result);
}
/* }}} */
| Exec Code | 0 | static int spl_ptr_heap_zval_min_cmp(spl_ptr_heap_element a, spl_ptr_heap_element b, void* object TSRMLS_DC) { /* {{{ */
zval result;
if (EG(exception)) {
return 0;
}
if (object) {
spl_heap_object *heap_object = (spl_heap_object*)zend_object_store_get_object((zval *)object TSRMLS_CC);
if (heap_object->fptr_cmp) {
long lval = 0;
if (spl_ptr_heap_cmp_cb_helper((zval *)object, heap_object, (zval *)a, (zval *)b, &lval TSRMLS_CC) == FAILURE) {
/* exception or call failure */
return 0;
}
return lval;
}
}
INIT_ZVAL(result);
compare_function(&result, (zval *)b, (zval *)a TSRMLS_CC);
return Z_LVAL(result);
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,980 | static int spl_ptr_pqueue_zval_cmp(spl_ptr_heap_element a, spl_ptr_heap_element b, void* object TSRMLS_DC) { /* {{{ */
zval result;
zval **a_priority_pp = spl_pqueue_extract_helper((zval **)&a, SPL_PQUEUE_EXTR_PRIORITY);
zval **b_priority_pp = spl_pqueue_extract_helper((zval **)&b, SPL_PQUEUE_EXTR_PRIORITY);
if ((!a_priority_pp) || (!b_priority_pp)) {
zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
return 0;
}
if (EG(exception)) {
return 0;
}
if (object) {
spl_heap_object *heap_object = (spl_heap_object*)zend_object_store_get_object(object TSRMLS_CC);
if (heap_object->fptr_cmp) {
long lval = 0;
if (spl_ptr_heap_cmp_cb_helper((zval *)object, heap_object, *a_priority_pp, *b_priority_pp, &lval TSRMLS_CC) == FAILURE) {
/* exception or call failure */
return 0;
}
return lval;
}
}
INIT_ZVAL(result);
compare_function(&result, *a_priority_pp, *b_priority_pp TSRMLS_CC);
return Z_LVAL(result);
}
/* }}} */
| Exec Code | 0 | static int spl_ptr_pqueue_zval_cmp(spl_ptr_heap_element a, spl_ptr_heap_element b, void* object TSRMLS_DC) { /* {{{ */
zval result;
zval **a_priority_pp = spl_pqueue_extract_helper((zval **)&a, SPL_PQUEUE_EXTR_PRIORITY);
zval **b_priority_pp = spl_pqueue_extract_helper((zval **)&b, SPL_PQUEUE_EXTR_PRIORITY);
if ((!a_priority_pp) || (!b_priority_pp)) {
zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
return 0;
}
if (EG(exception)) {
return 0;
}
if (object) {
spl_heap_object *heap_object = (spl_heap_object*)zend_object_store_get_object(object TSRMLS_CC);
if (heap_object->fptr_cmp) {
long lval = 0;
if (spl_ptr_heap_cmp_cb_helper((zval *)object, heap_object, *a_priority_pp, *b_priority_pp, &lval TSRMLS_CC) == FAILURE) {
/* exception or call failure */
return 0;
}
return lval;
}
}
INIT_ZVAL(result);
compare_function(&result, *a_priority_pp, *b_priority_pp TSRMLS_CC);
return Z_LVAL(result);
}
/* }}} */
| @@ -249,9 +249,10 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, spl_ptr_heap_element elem, v
heap->ctor(elem TSRMLS_CC);
/* sifting up */
- for(i = heap->count++; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
+ for(i = heap->count; i > 0 && heap->cmp(heap->elements[(i-1)/2], elem, cmp_userdata TSRMLS_CC) < 0; i = (i-1)/2) {
heap->elements[i] = heap->elements[(i-1)/2];
}
+ heap->count++;
if (EG(exception)) {
/* exception thrown during comparison */ | null | null | null |
11,981 | AttachOffloadGPU(ScreenPtr pScreen, ScreenPtr new)
{
assert(new->isGPU);
xorg_list_add(&new->offload_head, &pScreen->offload_slave_list);
new->current_master = pScreen;
}
| DoS | 0 | AttachOffloadGPU(ScreenPtr pScreen, ScreenPtr new)
{
assert(new->isGPU);
xorg_list_add(&new->offload_head, &pScreen->offload_slave_list);
new->current_master = pScreen;
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,982 | AttachUnboundGPU(ScreenPtr pScreen, ScreenPtr new)
{
assert(new->isGPU);
assert(!new->current_master);
xorg_list_add(&new->unattached_head, &pScreen->unattached_list);
new->current_master = pScreen;
}
| DoS | 0 | AttachUnboundGPU(ScreenPtr pScreen, ScreenPtr new)
{
assert(new->isGPU);
assert(!new->current_master);
xorg_list_add(&new->unattached_head, &pScreen->unattached_list);
new->current_master = pScreen;
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,983 | CloseDownClient(ClientPtr client)
{
Bool really_close_down = client->clientGone ||
client->closeDownMode == DestroyAll;
if (!client->clientGone) {
/* ungrab server if grabbing client dies */
if (grabState != GrabNone && grabClient == client) {
UngrabServer(client);
}
BITCLEAR(grabWaiters, client->index);
DeleteClientFromAnySelections(client);
ReleaseActiveGrabs(client);
DeleteClientFontStuff(client);
if (!really_close_down) {
/* This frees resources that should never be retained
* no matter what the close down mode is. Actually we
* could do this unconditionally, but it's probably
* better not to traverse all the client's resources
* twice (once here, once a few lines down in
* FreeClientResources) in the common case of
* really_close_down == TRUE.
*/
FreeClientNeverRetainResources(client);
client->clientState = ClientStateRetained;
if (ClientStateCallback) {
NewClientInfoRec clientinfo;
clientinfo.client = client;
clientinfo.prefix = (xConnSetupPrefix *) NULL;
clientinfo.setup = (xConnSetup *) NULL;
CallCallbacks((&ClientStateCallback), (void *) &clientinfo);
}
}
client->clientGone = TRUE; /* so events aren't sent to client */
if (ClientIsAsleep(client))
ClientSignal(client);
ProcessWorkQueueZombies();
CloseDownConnection(client);
/* If the client made it to the Running stage, nClients has
* been incremented on its behalf, so we need to decrement it
* now. If it hasn't gotten to Running, nClients has *not*
* been incremented, so *don't* decrement it.
*/
if (client->clientState != ClientStateInitial) {
--nClients;
}
}
if (really_close_down) {
if (client->clientState == ClientStateRunning && nClients == 0)
dispatchException |= dispatchExceptionAtReset;
client->clientState = ClientStateGone;
if (ClientStateCallback) {
NewClientInfoRec clientinfo;
clientinfo.client = client;
clientinfo.prefix = (xConnSetupPrefix *) NULL;
clientinfo.setup = (xConnSetup *) NULL;
CallCallbacks((&ClientStateCallback), (void *) &clientinfo);
}
TouchListenerGone(client->clientAsMask);
FreeClientResources(client);
/* Disable client ID tracking. This must be done after
* ClientStateCallback. */
ReleaseClientIds(client);
#ifdef XSERVER_DTRACE
XSERVER_CLIENT_DISCONNECT(client->index);
#endif
if (client->index < nextFreeClientID)
nextFreeClientID = client->index;
clients[client->index] = NullClient;
SmartLastClient = NullClient;
dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
while (!clients[currentMaxClients - 1])
currentMaxClients--;
}
}
| DoS | 0 | CloseDownClient(ClientPtr client)
{
Bool really_close_down = client->clientGone ||
client->closeDownMode == DestroyAll;
if (!client->clientGone) {
/* ungrab server if grabbing client dies */
if (grabState != GrabNone && grabClient == client) {
UngrabServer(client);
}
BITCLEAR(grabWaiters, client->index);
DeleteClientFromAnySelections(client);
ReleaseActiveGrabs(client);
DeleteClientFontStuff(client);
if (!really_close_down) {
/* This frees resources that should never be retained
* no matter what the close down mode is. Actually we
* could do this unconditionally, but it's probably
* better not to traverse all the client's resources
* twice (once here, once a few lines down in
* FreeClientResources) in the common case of
* really_close_down == TRUE.
*/
FreeClientNeverRetainResources(client);
client->clientState = ClientStateRetained;
if (ClientStateCallback) {
NewClientInfoRec clientinfo;
clientinfo.client = client;
clientinfo.prefix = (xConnSetupPrefix *) NULL;
clientinfo.setup = (xConnSetup *) NULL;
CallCallbacks((&ClientStateCallback), (void *) &clientinfo);
}
}
client->clientGone = TRUE; /* so events aren't sent to client */
if (ClientIsAsleep(client))
ClientSignal(client);
ProcessWorkQueueZombies();
CloseDownConnection(client);
/* If the client made it to the Running stage, nClients has
* been incremented on its behalf, so we need to decrement it
* now. If it hasn't gotten to Running, nClients has *not*
* been incremented, so *don't* decrement it.
*/
if (client->clientState != ClientStateInitial) {
--nClients;
}
}
if (really_close_down) {
if (client->clientState == ClientStateRunning && nClients == 0)
dispatchException |= dispatchExceptionAtReset;
client->clientState = ClientStateGone;
if (ClientStateCallback) {
NewClientInfoRec clientinfo;
clientinfo.client = client;
clientinfo.prefix = (xConnSetupPrefix *) NULL;
clientinfo.setup = (xConnSetup *) NULL;
CallCallbacks((&ClientStateCallback), (void *) &clientinfo);
}
TouchListenerGone(client->clientAsMask);
FreeClientResources(client);
/* Disable client ID tracking. This must be done after
* ClientStateCallback. */
ReleaseClientIds(client);
#ifdef XSERVER_DTRACE
XSERVER_CLIENT_DISCONNECT(client->index);
#endif
if (client->index < nextFreeClientID)
nextFreeClientID = client->index;
clients[client->index] = NullClient;
SmartLastClient = NullClient;
dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
while (!clients[currentMaxClients - 1])
currentMaxClients--;
}
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,984 | CloseDownRetainedResources(void)
{
int i;
ClientPtr client;
for (i = 1; i < currentMaxClients; i++) {
client = clients[i];
if (client && (client->closeDownMode == RetainTemporary)
&& (client->clientGone))
CloseDownClient(client);
}
}
| DoS | 0 | CloseDownRetainedResources(void)
{
int i;
ClientPtr client;
for (i = 1; i < currentMaxClients; i++) {
client = clients[i];
if (client && (client->closeDownMode == RetainTemporary)
&& (client->clientGone))
CloseDownClient(client);
}
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,985 | CreateConnectionBlock(void)
{
xConnSetup setup;
xWindowRoot root;
xDepth depth;
xVisualType visual;
xPixmapFormat format;
unsigned long vid;
int i, j, k, lenofblock, sizesofar = 0;
char *pBuf;
memset(&setup, 0, sizeof(xConnSetup));
/* Leave off the ridBase and ridMask, these must be sent with
connection */
setup.release = VendorRelease;
/*
* per-server image and bitmap parameters are defined in Xmd.h
*/
setup.imageByteOrder = screenInfo.imageByteOrder;
setup.bitmapScanlineUnit = screenInfo.bitmapScanlineUnit;
setup.bitmapScanlinePad = screenInfo.bitmapScanlinePad;
setup.bitmapBitOrder = screenInfo.bitmapBitOrder;
setup.motionBufferSize = NumMotionEvents();
setup.numRoots = screenInfo.numScreens;
setup.nbytesVendor = strlen(VendorString);
setup.numFormats = screenInfo.numPixmapFormats;
setup.maxRequestSize = MAX_REQUEST_SIZE;
QueryMinMaxKeyCodes(&setup.minKeyCode, &setup.maxKeyCode);
lenofblock = sizeof(xConnSetup) +
pad_to_int32(setup.nbytesVendor) +
(setup.numFormats * sizeof(xPixmapFormat)) +
(setup.numRoots * sizeof(xWindowRoot));
ConnectionInfo = malloc(lenofblock);
if (!ConnectionInfo)
return FALSE;
memmove(ConnectionInfo, (char *) &setup, sizeof(xConnSetup));
sizesofar = sizeof(xConnSetup);
pBuf = ConnectionInfo + sizeof(xConnSetup);
memmove(pBuf, VendorString, (int) setup.nbytesVendor);
sizesofar += setup.nbytesVendor;
pBuf += setup.nbytesVendor;
i = padding_for_int32(setup.nbytesVendor);
sizesofar += i;
while (--i >= 0)
*pBuf++ = 0;
memset(&format, 0, sizeof(xPixmapFormat));
for (i = 0; i < screenInfo.numPixmapFormats; i++) {
format.depth = screenInfo.formats[i].depth;
format.bitsPerPixel = screenInfo.formats[i].bitsPerPixel;
format.scanLinePad = screenInfo.formats[i].scanlinePad;
memmove(pBuf, (char *) &format, sizeof(xPixmapFormat));
pBuf += sizeof(xPixmapFormat);
sizesofar += sizeof(xPixmapFormat);
}
connBlockScreenStart = sizesofar;
memset(&depth, 0, sizeof(xDepth));
memset(&visual, 0, sizeof(xVisualType));
for (i = 0; i < screenInfo.numScreens; i++) {
ScreenPtr pScreen;
DepthPtr pDepth;
VisualPtr pVisual;
pScreen = screenInfo.screens[i];
root.windowId = pScreen->root->drawable.id;
root.defaultColormap = pScreen->defColormap;
root.whitePixel = pScreen->whitePixel;
root.blackPixel = pScreen->blackPixel;
root.currentInputMask = 0; /* filled in when sent */
root.pixWidth = pScreen->width;
root.pixHeight = pScreen->height;
root.mmWidth = pScreen->mmWidth;
root.mmHeight = pScreen->mmHeight;
root.minInstalledMaps = pScreen->minInstalledCmaps;
root.maxInstalledMaps = pScreen->maxInstalledCmaps;
root.rootVisualID = pScreen->rootVisual;
root.backingStore = pScreen->backingStoreSupport;
root.saveUnders = FALSE;
root.rootDepth = pScreen->rootDepth;
root.nDepths = pScreen->numDepths;
memmove(pBuf, (char *) &root, sizeof(xWindowRoot));
sizesofar += sizeof(xWindowRoot);
pBuf += sizeof(xWindowRoot);
pDepth = pScreen->allowedDepths;
for (j = 0; j < pScreen->numDepths; j++, pDepth++) {
lenofblock += sizeof(xDepth) +
(pDepth->numVids * sizeof(xVisualType));
pBuf = (char *) realloc(ConnectionInfo, lenofblock);
if (!pBuf) {
free(ConnectionInfo);
return FALSE;
}
ConnectionInfo = pBuf;
pBuf += sizesofar;
depth.depth = pDepth->depth;
depth.nVisuals = pDepth->numVids;
memmove(pBuf, (char *) &depth, sizeof(xDepth));
pBuf += sizeof(xDepth);
sizesofar += sizeof(xDepth);
for (k = 0; k < pDepth->numVids; k++) {
vid = pDepth->vids[k];
for (pVisual = pScreen->visuals;
pVisual->vid != vid; pVisual++);
visual.visualID = vid;
visual.class = pVisual->class;
visual.bitsPerRGB = pVisual->bitsPerRGBValue;
visual.colormapEntries = pVisual->ColormapEntries;
visual.redMask = pVisual->redMask;
visual.greenMask = pVisual->greenMask;
visual.blueMask = pVisual->blueMask;
memmove(pBuf, (char *) &visual, sizeof(xVisualType));
pBuf += sizeof(xVisualType);
sizesofar += sizeof(xVisualType);
}
}
}
connSetupPrefix.success = xTrue;
connSetupPrefix.length = lenofblock / 4;
connSetupPrefix.majorVersion = X_PROTOCOL;
connSetupPrefix.minorVersion = X_PROTOCOL_REVISION;
return TRUE;
}
| DoS | 0 | CreateConnectionBlock(void)
{
xConnSetup setup;
xWindowRoot root;
xDepth depth;
xVisualType visual;
xPixmapFormat format;
unsigned long vid;
int i, j, k, lenofblock, sizesofar = 0;
char *pBuf;
memset(&setup, 0, sizeof(xConnSetup));
/* Leave off the ridBase and ridMask, these must be sent with
connection */
setup.release = VendorRelease;
/*
* per-server image and bitmap parameters are defined in Xmd.h
*/
setup.imageByteOrder = screenInfo.imageByteOrder;
setup.bitmapScanlineUnit = screenInfo.bitmapScanlineUnit;
setup.bitmapScanlinePad = screenInfo.bitmapScanlinePad;
setup.bitmapBitOrder = screenInfo.bitmapBitOrder;
setup.motionBufferSize = NumMotionEvents();
setup.numRoots = screenInfo.numScreens;
setup.nbytesVendor = strlen(VendorString);
setup.numFormats = screenInfo.numPixmapFormats;
setup.maxRequestSize = MAX_REQUEST_SIZE;
QueryMinMaxKeyCodes(&setup.minKeyCode, &setup.maxKeyCode);
lenofblock = sizeof(xConnSetup) +
pad_to_int32(setup.nbytesVendor) +
(setup.numFormats * sizeof(xPixmapFormat)) +
(setup.numRoots * sizeof(xWindowRoot));
ConnectionInfo = malloc(lenofblock);
if (!ConnectionInfo)
return FALSE;
memmove(ConnectionInfo, (char *) &setup, sizeof(xConnSetup));
sizesofar = sizeof(xConnSetup);
pBuf = ConnectionInfo + sizeof(xConnSetup);
memmove(pBuf, VendorString, (int) setup.nbytesVendor);
sizesofar += setup.nbytesVendor;
pBuf += setup.nbytesVendor;
i = padding_for_int32(setup.nbytesVendor);
sizesofar += i;
while (--i >= 0)
*pBuf++ = 0;
memset(&format, 0, sizeof(xPixmapFormat));
for (i = 0; i < screenInfo.numPixmapFormats; i++) {
format.depth = screenInfo.formats[i].depth;
format.bitsPerPixel = screenInfo.formats[i].bitsPerPixel;
format.scanLinePad = screenInfo.formats[i].scanlinePad;
memmove(pBuf, (char *) &format, sizeof(xPixmapFormat));
pBuf += sizeof(xPixmapFormat);
sizesofar += sizeof(xPixmapFormat);
}
connBlockScreenStart = sizesofar;
memset(&depth, 0, sizeof(xDepth));
memset(&visual, 0, sizeof(xVisualType));
for (i = 0; i < screenInfo.numScreens; i++) {
ScreenPtr pScreen;
DepthPtr pDepth;
VisualPtr pVisual;
pScreen = screenInfo.screens[i];
root.windowId = pScreen->root->drawable.id;
root.defaultColormap = pScreen->defColormap;
root.whitePixel = pScreen->whitePixel;
root.blackPixel = pScreen->blackPixel;
root.currentInputMask = 0; /* filled in when sent */
root.pixWidth = pScreen->width;
root.pixHeight = pScreen->height;
root.mmWidth = pScreen->mmWidth;
root.mmHeight = pScreen->mmHeight;
root.minInstalledMaps = pScreen->minInstalledCmaps;
root.maxInstalledMaps = pScreen->maxInstalledCmaps;
root.rootVisualID = pScreen->rootVisual;
root.backingStore = pScreen->backingStoreSupport;
root.saveUnders = FALSE;
root.rootDepth = pScreen->rootDepth;
root.nDepths = pScreen->numDepths;
memmove(pBuf, (char *) &root, sizeof(xWindowRoot));
sizesofar += sizeof(xWindowRoot);
pBuf += sizeof(xWindowRoot);
pDepth = pScreen->allowedDepths;
for (j = 0; j < pScreen->numDepths; j++, pDepth++) {
lenofblock += sizeof(xDepth) +
(pDepth->numVids * sizeof(xVisualType));
pBuf = (char *) realloc(ConnectionInfo, lenofblock);
if (!pBuf) {
free(ConnectionInfo);
return FALSE;
}
ConnectionInfo = pBuf;
pBuf += sizesofar;
depth.depth = pDepth->depth;
depth.nVisuals = pDepth->numVids;
memmove(pBuf, (char *) &depth, sizeof(xDepth));
pBuf += sizeof(xDepth);
sizesofar += sizeof(xDepth);
for (k = 0; k < pDepth->numVids; k++) {
vid = pDepth->vids[k];
for (pVisual = pScreen->visuals;
pVisual->vid != vid; pVisual++);
visual.visualID = vid;
visual.class = pVisual->class;
visual.bitsPerRGB = pVisual->bitsPerRGBValue;
visual.colormapEntries = pVisual->ColormapEntries;
visual.redMask = pVisual->redMask;
visual.greenMask = pVisual->greenMask;
visual.blueMask = pVisual->blueMask;
memmove(pBuf, (char *) &visual, sizeof(xVisualType));
pBuf += sizeof(xVisualType);
sizesofar += sizeof(xVisualType);
}
}
}
connSetupPrefix.success = xTrue;
connSetupPrefix.length = lenofblock / 4;
connSetupPrefix.majorVersion = X_PROTOCOL;
connSetupPrefix.minorVersion = X_PROTOCOL_REVISION;
return TRUE;
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,986 | DetachOutputGPU(ScreenPtr slave)
{
assert(slave->isGPU);
xorg_list_del(&slave->output_head);
slave->current_master = NULL;
}
| DoS | 0 | DetachOutputGPU(ScreenPtr slave)
{
assert(slave->isGPU);
xorg_list_del(&slave->output_head);
slave->current_master = NULL;
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,987 | DisableLimitedSchedulingLatency(void)
{
--SmartScheduleLatencyLimited;
/* protect against bugs */
if (SmartScheduleLatencyLimited < 0)
SmartScheduleLatencyLimited = 0;
}
| DoS | 0 | DisableLimitedSchedulingLatency(void)
{
--SmartScheduleLatencyLimited;
/* protect against bugs */
if (SmartScheduleLatencyLimited < 0)
SmartScheduleLatencyLimited = 0;
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,988 | Dispatch(void)
{
int *clientReady; /* array of request ready clients */
int result;
ClientPtr client;
int nready;
HWEventQueuePtr *icheck = checkForInput;
long start_tick;
nextFreeClientID = 1;
nClients = 0;
clientReady = malloc(sizeof(int) * MaxClients);
if (!clientReady)
return;
SmartScheduleSlice = SmartScheduleInterval;
while (!dispatchException) {
if (*icheck[0] != *icheck[1]) {
ProcessInputEvents();
FlushIfCriticalOutputPending();
}
nready = WaitForSomething(clientReady);
if (nready && !SmartScheduleDisable) {
clientReady[0] = SmartScheduleClient(clientReady, nready);
nready = 1;
}
/*****************
* Handle events in round robin fashion, doing input between
* each round
*****************/
while (!dispatchException && (--nready >= 0)) {
client = clients[clientReady[nready]];
if (!client) {
/* KillClient can cause this to happen */
continue;
}
/* GrabServer activation can cause this to be true */
if (grabState == GrabKickout) {
grabState = GrabActive;
break;
}
isItTimeToYield = FALSE;
start_tick = SmartScheduleTime;
while (!isItTimeToYield) {
if (*icheck[0] != *icheck[1])
ProcessInputEvents();
FlushIfCriticalOutputPending();
if (!SmartScheduleDisable &&
(SmartScheduleTime - start_tick) >= SmartScheduleSlice) {
/* Penalize clients which consume ticks */
if (client->smart_priority > SMART_MIN_PRIORITY)
client->smart_priority--;
break;
}
/* now, finally, deal with client requests */
/* Update currentTime so request time checks, such as for input
* device grabs, are calculated correctly */
UpdateCurrentTimeIf();
result = ReadRequestFromClient(client);
if (result <= 0) {
if (result < 0)
CloseDownClient(client);
break;
}
client->sequence++;
client->majorOp = ((xReq *) client->requestBuffer)->reqType;
client->minorOp = 0;
if (client->majorOp >= EXTENSION_BASE) {
ExtensionEntry *ext = GetExtensionEntry(client->majorOp);
if (ext)
client->minorOp = ext->MinorOpcode(client);
}
#ifdef XSERVER_DTRACE
if (XSERVER_REQUEST_START_ENABLED())
XSERVER_REQUEST_START(LookupMajorName(client->majorOp),
client->majorOp,
((xReq *) client->requestBuffer)->length,
client->index,
client->requestBuffer);
#endif
if (result > (maxBigRequestSize << 2))
result = BadLength;
else {
result = XaceHookDispatch(client, client->majorOp);
if (result == Success)
result =
(*client->requestVector[client->majorOp]) (client);
XaceHookAuditEnd(client, result);
}
#ifdef XSERVER_DTRACE
if (XSERVER_REQUEST_DONE_ENABLED())
XSERVER_REQUEST_DONE(LookupMajorName(client->majorOp),
client->majorOp, client->sequence,
client->index, result);
#endif
if (client->noClientException != Success) {
CloseDownClient(client);
break;
}
else if (result != Success) {
SendErrorToClient(client, client->majorOp,
client->minorOp,
client->errorValue, result);
break;
}
}
FlushAllOutput();
client = clients[clientReady[nready]];
if (client)
client->smart_stop_tick = SmartScheduleTime;
}
dispatchException &= ~DE_PRIORITYCHANGE;
}
#if defined(DDXBEFORERESET)
ddxBeforeReset();
#endif
KillAllClients();
free(clientReady);
dispatchException &= ~DE_RESET;
SmartScheduleLatencyLimited = 0;
ResetOsBuffers();
}
| DoS | 0 | Dispatch(void)
{
int *clientReady; /* array of request ready clients */
int result;
ClientPtr client;
int nready;
HWEventQueuePtr *icheck = checkForInput;
long start_tick;
nextFreeClientID = 1;
nClients = 0;
clientReady = malloc(sizeof(int) * MaxClients);
if (!clientReady)
return;
SmartScheduleSlice = SmartScheduleInterval;
while (!dispatchException) {
if (*icheck[0] != *icheck[1]) {
ProcessInputEvents();
FlushIfCriticalOutputPending();
}
nready = WaitForSomething(clientReady);
if (nready && !SmartScheduleDisable) {
clientReady[0] = SmartScheduleClient(clientReady, nready);
nready = 1;
}
/*****************
* Handle events in round robin fashion, doing input between
* each round
*****************/
while (!dispatchException && (--nready >= 0)) {
client = clients[clientReady[nready]];
if (!client) {
/* KillClient can cause this to happen */
continue;
}
/* GrabServer activation can cause this to be true */
if (grabState == GrabKickout) {
grabState = GrabActive;
break;
}
isItTimeToYield = FALSE;
start_tick = SmartScheduleTime;
while (!isItTimeToYield) {
if (*icheck[0] != *icheck[1])
ProcessInputEvents();
FlushIfCriticalOutputPending();
if (!SmartScheduleDisable &&
(SmartScheduleTime - start_tick) >= SmartScheduleSlice) {
/* Penalize clients which consume ticks */
if (client->smart_priority > SMART_MIN_PRIORITY)
client->smart_priority--;
break;
}
/* now, finally, deal with client requests */
/* Update currentTime so request time checks, such as for input
* device grabs, are calculated correctly */
UpdateCurrentTimeIf();
result = ReadRequestFromClient(client);
if (result <= 0) {
if (result < 0)
CloseDownClient(client);
break;
}
client->sequence++;
client->majorOp = ((xReq *) client->requestBuffer)->reqType;
client->minorOp = 0;
if (client->majorOp >= EXTENSION_BASE) {
ExtensionEntry *ext = GetExtensionEntry(client->majorOp);
if (ext)
client->minorOp = ext->MinorOpcode(client);
}
#ifdef XSERVER_DTRACE
if (XSERVER_REQUEST_START_ENABLED())
XSERVER_REQUEST_START(LookupMajorName(client->majorOp),
client->majorOp,
((xReq *) client->requestBuffer)->length,
client->index,
client->requestBuffer);
#endif
if (result > (maxBigRequestSize << 2))
result = BadLength;
else {
result = XaceHookDispatch(client, client->majorOp);
if (result == Success)
result =
(*client->requestVector[client->majorOp]) (client);
XaceHookAuditEnd(client, result);
}
#ifdef XSERVER_DTRACE
if (XSERVER_REQUEST_DONE_ENABLED())
XSERVER_REQUEST_DONE(LookupMajorName(client->majorOp),
client->majorOp, client->sequence,
client->index, result);
#endif
if (client->noClientException != Success) {
CloseDownClient(client);
break;
}
else if (result != Success) {
SendErrorToClient(client, client->majorOp,
client->minorOp,
client->errorValue, result);
break;
}
}
FlushAllOutput();
client = clients[clientReady[nready]];
if (client)
client->smart_stop_tick = SmartScheduleTime;
}
dispatchException &= ~DE_PRIORITYCHANGE;
}
#if defined(DDXBEFORERESET)
ddxBeforeReset();
#endif
KillAllClients();
free(clientReady);
dispatchException &= ~DE_RESET;
SmartScheduleLatencyLimited = 0;
ResetOsBuffers();
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,989 | DoGetImage(ClientPtr client, int format, Drawable drawable,
int x, int y, int width, int height,
Mask planemask)
{
DrawablePtr pDraw, pBoundingDraw;
int nlines, linesPerBuf, rc;
int linesDone;
/* coordinates relative to the bounding drawable */
int relx, rely;
long widthBytesLine, length;
Mask plane = 0;
char *pBuf;
xGetImageReply xgi;
RegionPtr pVisibleRegion = NULL;
if ((format != XYPixmap) && (format != ZPixmap)) {
client->errorValue = format;
return BadValue;
}
rc = dixLookupDrawable(&pDraw, drawable, client, 0, DixReadAccess);
if (rc != Success)
return rc;
memset(&xgi, 0, sizeof(xGetImageReply));
relx = x;
rely = y;
if (pDraw->type == DRAWABLE_WINDOW) {
WindowPtr pWin = (WindowPtr) pDraw;
/* "If the drawable is a window, the window must be viewable ... or a
* BadMatch error results" */
if (!pWin->viewable)
return BadMatch;
/* If the drawable is a window, the rectangle must be contained within
* its bounds (including the border). */
if (x < -wBorderWidth(pWin) ||
x + width > wBorderWidth(pWin) + (int) pDraw->width ||
y < -wBorderWidth(pWin) ||
y + height > wBorderWidth(pWin) + (int) pDraw->height)
return BadMatch;
relx += pDraw->x;
rely += pDraw->y;
if (pDraw->pScreen->GetWindowPixmap) {
PixmapPtr pPix = (*pDraw->pScreen->GetWindowPixmap) (pWin);
pBoundingDraw = &pPix->drawable;
#ifdef COMPOSITE
relx -= pPix->screen_x;
rely -= pPix->screen_y;
#endif
}
else {
pBoundingDraw = (DrawablePtr) pDraw->pScreen->root;
}
xgi.visual = wVisual(pWin);
}
else {
pBoundingDraw = pDraw;
xgi.visual = None;
}
/* "If the drawable is a pixmap, the given rectangle must be wholly
* contained within the pixmap, or a BadMatch error results. If the
* drawable is a window [...] it must be the case that if there were no
* inferiors or overlapping windows, the specified rectangle of the window
* would be fully visible on the screen and wholly contained within the
* outside edges of the window, or a BadMatch error results."
*
* We relax the window case slightly to mean that the rectangle must exist
* within the bounds of the window's backing pixmap. In particular, this
* means that a GetImage request may succeed or fail with BadMatch depending
* on whether any of its ancestor windows are redirected. */
if (relx < 0 || relx + width > (int) pBoundingDraw->width ||
rely < 0 || rely + height > (int) pBoundingDraw->height)
return BadMatch;
xgi.type = X_Reply;
xgi.sequenceNumber = client->sequence;
xgi.depth = pDraw->depth;
if (format == ZPixmap) {
widthBytesLine = PixmapBytePad(width, pDraw->depth);
length = widthBytesLine * height;
}
else {
widthBytesLine = BitmapBytePad(width);
plane = ((Mask) 1) << (pDraw->depth - 1);
/* only planes asked for */
length = widthBytesLine * height *
Ones(planemask & (plane | (plane - 1)));
}
xgi.length = length;
xgi.length = bytes_to_int32(xgi.length);
if (widthBytesLine == 0 || height == 0)
linesPerBuf = 0;
else if (widthBytesLine >= IMAGE_BUFSIZE)
linesPerBuf = 1;
else {
linesPerBuf = IMAGE_BUFSIZE / widthBytesLine;
if (linesPerBuf > height)
linesPerBuf = height;
}
length = linesPerBuf * widthBytesLine;
if (linesPerBuf < height) {
/* we have to make sure intermediate buffers don't need padding */
while ((linesPerBuf > 1) &&
(length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD) - 1))) {
linesPerBuf--;
length -= widthBytesLine;
}
while (length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD) - 1)) {
linesPerBuf++;
length += widthBytesLine;
}
}
if (!(pBuf = calloc(1, length)))
return BadAlloc;
WriteReplyToClient(client, sizeof(xGetImageReply), &xgi);
if (pDraw->type == DRAWABLE_WINDOW) {
pVisibleRegion = NotClippedByChildren((WindowPtr) pDraw);
if (pVisibleRegion) {
RegionTranslate(pVisibleRegion, -pDraw->x, -pDraw->y);
}
}
if (linesPerBuf == 0) {
/* nothing to do */
}
else if (format == ZPixmap) {
linesDone = 0;
while (height - linesDone > 0) {
nlines = min(linesPerBuf, height - linesDone);
(*pDraw->pScreen->GetImage) (pDraw,
x,
y + linesDone,
width,
nlines,
format, planemask, (void *) pBuf);
if (pVisibleRegion)
XaceCensorImage(client, pVisibleRegion, widthBytesLine,
pDraw, x, y + linesDone, width,
nlines, format, pBuf);
/* Note that this is NOT a call to WriteSwappedDataToClient,
as we do NOT byte swap */
ReformatImage(pBuf, (int) (nlines * widthBytesLine),
BitsPerPixel(pDraw->depth), ClientOrder(client));
WriteToClient(client, (int) (nlines * widthBytesLine), pBuf);
linesDone += nlines;
}
}
else { /* XYPixmap */
for (; plane; plane >>= 1) {
if (planemask & plane) {
linesDone = 0;
while (height - linesDone > 0) {
nlines = min(linesPerBuf, height - linesDone);
(*pDraw->pScreen->GetImage) (pDraw,
x,
y + linesDone,
width,
nlines,
format, plane, (void *) pBuf);
if (pVisibleRegion)
XaceCensorImage(client, pVisibleRegion,
widthBytesLine,
pDraw, x, y + linesDone, width,
nlines, format, pBuf);
/* Note: NOT a call to WriteSwappedDataToClient,
as we do NOT byte swap */
ReformatImage(pBuf, (int) (nlines * widthBytesLine),
1, ClientOrder(client));
WriteToClient(client, (int)(nlines * widthBytesLine), pBuf);
linesDone += nlines;
}
}
}
}
if (pVisibleRegion)
RegionDestroy(pVisibleRegion);
free(pBuf);
return Success;
}
| DoS | 0 | DoGetImage(ClientPtr client, int format, Drawable drawable,
int x, int y, int width, int height,
Mask planemask)
{
DrawablePtr pDraw, pBoundingDraw;
int nlines, linesPerBuf, rc;
int linesDone;
/* coordinates relative to the bounding drawable */
int relx, rely;
long widthBytesLine, length;
Mask plane = 0;
char *pBuf;
xGetImageReply xgi;
RegionPtr pVisibleRegion = NULL;
if ((format != XYPixmap) && (format != ZPixmap)) {
client->errorValue = format;
return BadValue;
}
rc = dixLookupDrawable(&pDraw, drawable, client, 0, DixReadAccess);
if (rc != Success)
return rc;
memset(&xgi, 0, sizeof(xGetImageReply));
relx = x;
rely = y;
if (pDraw->type == DRAWABLE_WINDOW) {
WindowPtr pWin = (WindowPtr) pDraw;
/* "If the drawable is a window, the window must be viewable ... or a
* BadMatch error results" */
if (!pWin->viewable)
return BadMatch;
/* If the drawable is a window, the rectangle must be contained within
* its bounds (including the border). */
if (x < -wBorderWidth(pWin) ||
x + width > wBorderWidth(pWin) + (int) pDraw->width ||
y < -wBorderWidth(pWin) ||
y + height > wBorderWidth(pWin) + (int) pDraw->height)
return BadMatch;
relx += pDraw->x;
rely += pDraw->y;
if (pDraw->pScreen->GetWindowPixmap) {
PixmapPtr pPix = (*pDraw->pScreen->GetWindowPixmap) (pWin);
pBoundingDraw = &pPix->drawable;
#ifdef COMPOSITE
relx -= pPix->screen_x;
rely -= pPix->screen_y;
#endif
}
else {
pBoundingDraw = (DrawablePtr) pDraw->pScreen->root;
}
xgi.visual = wVisual(pWin);
}
else {
pBoundingDraw = pDraw;
xgi.visual = None;
}
/* "If the drawable is a pixmap, the given rectangle must be wholly
* contained within the pixmap, or a BadMatch error results. If the
* drawable is a window [...] it must be the case that if there were no
* inferiors or overlapping windows, the specified rectangle of the window
* would be fully visible on the screen and wholly contained within the
* outside edges of the window, or a BadMatch error results."
*
* We relax the window case slightly to mean that the rectangle must exist
* within the bounds of the window's backing pixmap. In particular, this
* means that a GetImage request may succeed or fail with BadMatch depending
* on whether any of its ancestor windows are redirected. */
if (relx < 0 || relx + width > (int) pBoundingDraw->width ||
rely < 0 || rely + height > (int) pBoundingDraw->height)
return BadMatch;
xgi.type = X_Reply;
xgi.sequenceNumber = client->sequence;
xgi.depth = pDraw->depth;
if (format == ZPixmap) {
widthBytesLine = PixmapBytePad(width, pDraw->depth);
length = widthBytesLine * height;
}
else {
widthBytesLine = BitmapBytePad(width);
plane = ((Mask) 1) << (pDraw->depth - 1);
/* only planes asked for */
length = widthBytesLine * height *
Ones(planemask & (plane | (plane - 1)));
}
xgi.length = length;
xgi.length = bytes_to_int32(xgi.length);
if (widthBytesLine == 0 || height == 0)
linesPerBuf = 0;
else if (widthBytesLine >= IMAGE_BUFSIZE)
linesPerBuf = 1;
else {
linesPerBuf = IMAGE_BUFSIZE / widthBytesLine;
if (linesPerBuf > height)
linesPerBuf = height;
}
length = linesPerBuf * widthBytesLine;
if (linesPerBuf < height) {
/* we have to make sure intermediate buffers don't need padding */
while ((linesPerBuf > 1) &&
(length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD) - 1))) {
linesPerBuf--;
length -= widthBytesLine;
}
while (length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD) - 1)) {
linesPerBuf++;
length += widthBytesLine;
}
}
if (!(pBuf = calloc(1, length)))
return BadAlloc;
WriteReplyToClient(client, sizeof(xGetImageReply), &xgi);
if (pDraw->type == DRAWABLE_WINDOW) {
pVisibleRegion = NotClippedByChildren((WindowPtr) pDraw);
if (pVisibleRegion) {
RegionTranslate(pVisibleRegion, -pDraw->x, -pDraw->y);
}
}
if (linesPerBuf == 0) {
/* nothing to do */
}
else if (format == ZPixmap) {
linesDone = 0;
while (height - linesDone > 0) {
nlines = min(linesPerBuf, height - linesDone);
(*pDraw->pScreen->GetImage) (pDraw,
x,
y + linesDone,
width,
nlines,
format, planemask, (void *) pBuf);
if (pVisibleRegion)
XaceCensorImage(client, pVisibleRegion, widthBytesLine,
pDraw, x, y + linesDone, width,
nlines, format, pBuf);
/* Note that this is NOT a call to WriteSwappedDataToClient,
as we do NOT byte swap */
ReformatImage(pBuf, (int) (nlines * widthBytesLine),
BitsPerPixel(pDraw->depth), ClientOrder(client));
WriteToClient(client, (int) (nlines * widthBytesLine), pBuf);
linesDone += nlines;
}
}
else { /* XYPixmap */
for (; plane; plane >>= 1) {
if (planemask & plane) {
linesDone = 0;
while (height - linesDone > 0) {
nlines = min(linesPerBuf, height - linesDone);
(*pDraw->pScreen->GetImage) (pDraw,
x,
y + linesDone,
width,
nlines,
format, plane, (void *) pBuf);
if (pVisibleRegion)
XaceCensorImage(client, pVisibleRegion,
widthBytesLine,
pDraw, x, y + linesDone, width,
nlines, format, pBuf);
/* Note: NOT a call to WriteSwappedDataToClient,
as we do NOT byte swap */
ReformatImage(pBuf, (int) (nlines * widthBytesLine),
1, ClientOrder(client));
WriteToClient(client, (int)(nlines * widthBytesLine), pBuf);
linesDone += nlines;
}
}
}
}
if (pVisibleRegion)
RegionDestroy(pVisibleRegion);
free(pBuf);
return Success;
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,990 | EnableLimitedSchedulingLatency(void)
{
++SmartScheduleLatencyLimited;
SmartScheduleSlice = SmartScheduleInterval;
}
| DoS | 0 | EnableLimitedSchedulingLatency(void)
{
++SmartScheduleLatencyLimited;
SmartScheduleSlice = SmartScheduleInterval;
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,991 | GetGeometry(ClientPtr client, xGetGeometryReply * rep)
{
DrawablePtr pDraw;
int rc;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupDrawable(&pDraw, stuff->id, client, M_ANY, DixGetAttrAccess);
if (rc != Success)
return rc;
rep->type = X_Reply;
rep->length = 0;
rep->sequenceNumber = client->sequence;
rep->root = pDraw->pScreen->root->drawable.id;
rep->depth = pDraw->depth;
rep->width = pDraw->width;
rep->height = pDraw->height;
if (WindowDrawable(pDraw->type)) {
WindowPtr pWin = (WindowPtr) pDraw;
rep->x = pWin->origin.x - wBorderWidth(pWin);
rep->y = pWin->origin.y - wBorderWidth(pWin);
rep->borderWidth = pWin->borderWidth;
}
else { /* DRAWABLE_PIXMAP */
rep->x = rep->y = rep->borderWidth = 0;
}
return Success;
}
| DoS | 0 | GetGeometry(ClientPtr client, xGetGeometryReply * rep)
{
DrawablePtr pDraw;
int rc;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
rc = dixLookupDrawable(&pDraw, stuff->id, client, M_ANY, DixGetAttrAccess);
if (rc != Success)
return rc;
rep->type = X_Reply;
rep->length = 0;
rep->sequenceNumber = client->sequence;
rep->root = pDraw->pScreen->root->drawable.id;
rep->depth = pDraw->depth;
rep->width = pDraw->width;
rep->height = pDraw->height;
if (WindowDrawable(pDraw->type)) {
WindowPtr pWin = (WindowPtr) pDraw;
rep->x = pWin->origin.x - wBorderWidth(pWin);
rep->y = pWin->origin.y - wBorderWidth(pWin);
rep->borderWidth = pWin->borderWidth;
}
else { /* DRAWABLE_PIXMAP */
rep->x = rep->y = rep->borderWidth = 0;
}
return Success;
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,992 | KillAllClients(void)
{
int i;
for (i = 1; i < currentMaxClients; i++)
if (clients[i]) {
/* Make sure Retained clients are released. */
clients[i]->closeDownMode = DestroyAll;
CloseDownClient(clients[i]);
}
}
| DoS | 0 | KillAllClients(void)
{
int i;
for (i = 1; i < currentMaxClients; i++)
if (clients[i]) {
/* Make sure Retained clients are released. */
clients[i]->closeDownMode = DestroyAll;
CloseDownClient(clients[i]);
}
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,993 | MarkClientException(ClientPtr client)
{
client->noClientException = -1;
}
| DoS | 0 | MarkClientException(ClientPtr client)
{
client->noClientException = -1;
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,994 | NextAvailableClient(void *ospriv)
{
int i;
ClientPtr client;
xReq data;
i = nextFreeClientID;
if (i == MAXCLIENTS)
return (ClientPtr) NULL;
clients[i] = client =
dixAllocateObjectWithPrivates(ClientRec, PRIVATE_CLIENT);
if (!client)
return (ClientPtr) NULL;
InitClient(client, i, ospriv);
if (!InitClientResources(client)) {
dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
return (ClientPtr) NULL;
}
data.reqType = 1;
data.length = bytes_to_int32(sz_xReq + sz_xConnClientPrefix);
if (!InsertFakeRequest(client, (char *) &data, sz_xReq)) {
FreeClientResources(client);
dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
return (ClientPtr) NULL;
}
if (i == currentMaxClients)
currentMaxClients++;
while ((nextFreeClientID < MAXCLIENTS) && clients[nextFreeClientID])
nextFreeClientID++;
/* Enable client ID tracking. This must be done before
* ClientStateCallback. */
ReserveClientIds(client);
if (ClientStateCallback) {
NewClientInfoRec clientinfo;
clientinfo.client = client;
clientinfo.prefix = (xConnSetupPrefix *) NULL;
clientinfo.setup = (xConnSetup *) NULL;
CallCallbacks((&ClientStateCallback), (void *) &clientinfo);
}
return client;
}
| DoS | 0 | NextAvailableClient(void *ospriv)
{
int i;
ClientPtr client;
xReq data;
i = nextFreeClientID;
if (i == MAXCLIENTS)
return (ClientPtr) NULL;
clients[i] = client =
dixAllocateObjectWithPrivates(ClientRec, PRIVATE_CLIENT);
if (!client)
return (ClientPtr) NULL;
InitClient(client, i, ospriv);
if (!InitClientResources(client)) {
dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
return (ClientPtr) NULL;
}
data.reqType = 1;
data.length = bytes_to_int32(sz_xReq + sz_xConnClientPrefix);
if (!InsertFakeRequest(client, (char *) &data, sz_xReq)) {
FreeClientResources(client);
dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
return (ClientPtr) NULL;
}
if (i == currentMaxClients)
currentMaxClients++;
while ((nextFreeClientID < MAXCLIENTS) && clients[nextFreeClientID])
nextFreeClientID++;
/* Enable client ID tracking. This must be done before
* ClientStateCallback. */
ReserveClientIds(client);
if (ClientStateCallback) {
NewClientInfoRec clientinfo;
clientinfo.client = client;
clientinfo.prefix = (xConnSetupPrefix *) NULL;
clientinfo.setup = (xConnSetup *) NULL;
CallCallbacks((&ClientStateCallback), (void *) &clientinfo);
}
return client;
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,995 | ProcAllocColor(ClientPtr client)
{
ColormapPtr pmap;
int rc;
REQUEST(xAllocColorReq);
REQUEST_SIZE_MATCH(xAllocColorReq);
rc = dixLookupResourceByType((void **) &pmap, stuff->cmap, RT_COLORMAP,
client, DixAddAccess);
if (rc == Success) {
xAllocColorReply acr = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.red = stuff->red,
.green = stuff->green,
.blue = stuff->blue,
.pixel = 0
};
if ((rc = AllocColor(pmap, &acr.red, &acr.green, &acr.blue,
&acr.pixel, client->index)))
return rc;
#ifdef PANORAMIX
if (noPanoramiXExtension || !pmap->pScreen->myNum)
#endif
WriteReplyToClient(client, sizeof(xAllocColorReply), &acr);
return Success;
}
else {
client->errorValue = stuff->cmap;
return rc;
}
}
| DoS | 0 | ProcAllocColor(ClientPtr client)
{
ColormapPtr pmap;
int rc;
REQUEST(xAllocColorReq);
REQUEST_SIZE_MATCH(xAllocColorReq);
rc = dixLookupResourceByType((void **) &pmap, stuff->cmap, RT_COLORMAP,
client, DixAddAccess);
if (rc == Success) {
xAllocColorReply acr = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.red = stuff->red,
.green = stuff->green,
.blue = stuff->blue,
.pixel = 0
};
if ((rc = AllocColor(pmap, &acr.red, &acr.green, &acr.blue,
&acr.pixel, client->index)))
return rc;
#ifdef PANORAMIX
if (noPanoramiXExtension || !pmap->pScreen->myNum)
#endif
WriteReplyToClient(client, sizeof(xAllocColorReply), &acr);
return Success;
}
else {
client->errorValue = stuff->cmap;
return rc;
}
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,996 | ProcAllocColorCells(ClientPtr client)
{
ColormapPtr pcmp;
int rc;
REQUEST(xAllocColorCellsReq);
REQUEST_SIZE_MATCH(xAllocColorCellsReq);
rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
client, DixAddAccess);
if (rc == Success) {
int npixels, nmasks;
long length;
Pixel *ppixels, *pmasks;
npixels = stuff->colors;
if (!npixels) {
client->errorValue = npixels;
return BadValue;
}
if (stuff->contiguous != xTrue && stuff->contiguous != xFalse) {
client->errorValue = stuff->contiguous;
return BadValue;
}
nmasks = stuff->planes;
length = ((long) npixels + (long) nmasks) * sizeof(Pixel);
ppixels = malloc(length);
if (!ppixels)
return BadAlloc;
pmasks = ppixels + npixels;
if ((rc = AllocColorCells(client->index, pcmp, npixels, nmasks,
(Bool) stuff->contiguous, ppixels, pmasks))) {
free(ppixels);
return rc;
}
#ifdef PANORAMIX
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
#endif
{
xAllocColorCellsReply accr = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(length),
.nPixels = npixels,
.nMasks = nmasks
};
WriteReplyToClient(client, sizeof(xAllocColorCellsReply), &accr);
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, length, ppixels);
}
free(ppixels);
return Success;
}
else {
client->errorValue = stuff->cmap;
return rc;
}
}
| DoS | 0 | ProcAllocColorCells(ClientPtr client)
{
ColormapPtr pcmp;
int rc;
REQUEST(xAllocColorCellsReq);
REQUEST_SIZE_MATCH(xAllocColorCellsReq);
rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
client, DixAddAccess);
if (rc == Success) {
int npixels, nmasks;
long length;
Pixel *ppixels, *pmasks;
npixels = stuff->colors;
if (!npixels) {
client->errorValue = npixels;
return BadValue;
}
if (stuff->contiguous != xTrue && stuff->contiguous != xFalse) {
client->errorValue = stuff->contiguous;
return BadValue;
}
nmasks = stuff->planes;
length = ((long) npixels + (long) nmasks) * sizeof(Pixel);
ppixels = malloc(length);
if (!ppixels)
return BadAlloc;
pmasks = ppixels + npixels;
if ((rc = AllocColorCells(client->index, pcmp, npixels, nmasks,
(Bool) stuff->contiguous, ppixels, pmasks))) {
free(ppixels);
return rc;
}
#ifdef PANORAMIX
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
#endif
{
xAllocColorCellsReply accr = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(length),
.nPixels = npixels,
.nMasks = nmasks
};
WriteReplyToClient(client, sizeof(xAllocColorCellsReply), &accr);
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, length, ppixels);
}
free(ppixels);
return Success;
}
else {
client->errorValue = stuff->cmap;
return rc;
}
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,997 | ProcAllocColorPlanes(ClientPtr client)
{
ColormapPtr pcmp;
int rc;
REQUEST(xAllocColorPlanesReq);
REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
client, DixAddAccess);
if (rc == Success) {
xAllocColorPlanesReply acpr;
int npixels;
long length;
Pixel *ppixels;
npixels = stuff->colors;
if (!npixels) {
client->errorValue = npixels;
return BadValue;
}
if (stuff->contiguous != xTrue && stuff->contiguous != xFalse) {
client->errorValue = stuff->contiguous;
return BadValue;
}
acpr = (xAllocColorPlanesReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.nPixels = npixels
};
length = (long) npixels *sizeof(Pixel);
ppixels = malloc(length);
if (!ppixels)
return BadAlloc;
if ((rc = AllocColorPlanes(client->index, pcmp, npixels,
(int) stuff->red, (int) stuff->green,
(int) stuff->blue, (Bool) stuff->contiguous,
ppixels, &acpr.redMask, &acpr.greenMask,
&acpr.blueMask))) {
free(ppixels);
return rc;
}
acpr.length = bytes_to_int32(length);
#ifdef PANORAMIX
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
#endif
{
WriteReplyToClient(client, sizeof(xAllocColorPlanesReply), &acpr);
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, length, ppixels);
}
free(ppixels);
return Success;
}
else {
client->errorValue = stuff->cmap;
return rc;
}
}
| DoS | 0 | ProcAllocColorPlanes(ClientPtr client)
{
ColormapPtr pcmp;
int rc;
REQUEST(xAllocColorPlanesReq);
REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
client, DixAddAccess);
if (rc == Success) {
xAllocColorPlanesReply acpr;
int npixels;
long length;
Pixel *ppixels;
npixels = stuff->colors;
if (!npixels) {
client->errorValue = npixels;
return BadValue;
}
if (stuff->contiguous != xTrue && stuff->contiguous != xFalse) {
client->errorValue = stuff->contiguous;
return BadValue;
}
acpr = (xAllocColorPlanesReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.nPixels = npixels
};
length = (long) npixels *sizeof(Pixel);
ppixels = malloc(length);
if (!ppixels)
return BadAlloc;
if ((rc = AllocColorPlanes(client->index, pcmp, npixels,
(int) stuff->red, (int) stuff->green,
(int) stuff->blue, (Bool) stuff->contiguous,
ppixels, &acpr.redMask, &acpr.greenMask,
&acpr.blueMask))) {
free(ppixels);
return rc;
}
acpr.length = bytes_to_int32(length);
#ifdef PANORAMIX
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
#endif
{
WriteReplyToClient(client, sizeof(xAllocColorPlanesReply), &acpr);
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, length, ppixels);
}
free(ppixels);
return Success;
}
else {
client->errorValue = stuff->cmap;
return rc;
}
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,998 | ProcAllocNamedColor(ClientPtr client)
{
ColormapPtr pcmp;
int rc;
REQUEST(xAllocNamedColorReq);
REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes);
rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
client, DixAddAccess);
if (rc == Success) {
xAllocNamedColorReply ancr = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0
};
if (OsLookupColor
(pcmp->pScreen->myNum, (char *) &stuff[1], stuff->nbytes,
&ancr.exactRed, &ancr.exactGreen, &ancr.exactBlue)) {
ancr.screenRed = ancr.exactRed;
ancr.screenGreen = ancr.exactGreen;
ancr.screenBlue = ancr.exactBlue;
ancr.pixel = 0;
if ((rc = AllocColor(pcmp,
&ancr.screenRed, &ancr.screenGreen,
&ancr.screenBlue, &ancr.pixel, client->index)))
return rc;
#ifdef PANORAMIX
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
#endif
WriteReplyToClient(client, sizeof(xAllocNamedColorReply),
&ancr);
return Success;
}
else
return BadName;
}
else {
client->errorValue = stuff->cmap;
return rc;
}
}
| DoS | 0 | ProcAllocNamedColor(ClientPtr client)
{
ColormapPtr pcmp;
int rc;
REQUEST(xAllocNamedColorReq);
REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes);
rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP,
client, DixAddAccess);
if (rc == Success) {
xAllocNamedColorReply ancr = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0
};
if (OsLookupColor
(pcmp->pScreen->myNum, (char *) &stuff[1], stuff->nbytes,
&ancr.exactRed, &ancr.exactGreen, &ancr.exactBlue)) {
ancr.screenRed = ancr.exactRed;
ancr.screenGreen = ancr.exactGreen;
ancr.screenBlue = ancr.exactBlue;
ancr.pixel = 0;
if ((rc = AllocColor(pcmp,
&ancr.screenRed, &ancr.screenGreen,
&ancr.screenBlue, &ancr.pixel, client->index)))
return rc;
#ifdef PANORAMIX
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
#endif
WriteReplyToClient(client, sizeof(xAllocNamedColorReply),
&ancr);
return Success;
}
else
return BadName;
}
else {
client->errorValue = stuff->cmap;
return rc;
}
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
11,999 | ProcBadRequest(ClientPtr client)
{
return BadRequest;
}
| DoS | 0 | ProcBadRequest(ClientPtr client)
{
return BadRequest;
}
| @@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client)
tmpImage = (char *) &stuff[1];
lengthProto = length;
- if (lengthProto >= (INT32_MAX / stuff->height))
+ if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height))
return BadLength;
if ((bytes_to_int32(lengthProto * stuff->height) + | CWE-369 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.