This commit is contained in:
Dmitry Stogov 2014-08-13 19:43:34 +04:00
parent c1c913c5f1
commit a08b7b7701
8 changed files with 193 additions and 248 deletions

View File

@ -4556,7 +4556,7 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, int calc_su
int rs;
timelib_time *t;
timelib_tzinfo *tzi;
char *retstr;
zend_string *retstr;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|ldddd", &time, &retformat, &latitude, &longitude, &zenith, &gmt_offset) == FAILURE) {
RETURN_FALSE;
@ -4621,11 +4621,8 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, int calc_su
switch (retformat) {
case SUNFUNCS_RET_STRING:
spprintf(&retstr, 0, "%02d:%02d", (int) N, (int) (60 * (N - (int) N)));
// TODO: avoid reallocation ???
RETVAL_STRINGL(retstr, 5);
efree(retstr);
return;
retstr = strpprintf(0, "%02d:%02d", (int) N, (int) (60 * (N - (int) N)));
RETURN_STR(retstr);
break;
case SUNFUNCS_RET_DOUBLE:
RETURN_DOUBLE(N);

View File

@ -76,8 +76,8 @@ MAILSTREAM DEFAULTPROTO;
static void _php_make_header_object(zval *myzvalue, ENVELOPE *en TSRMLS_DC);
static void _php_imap_add_body(zval *arg, BODY *body TSRMLS_DC);
static char* _php_imap_parse_address(ADDRESS *addresslist, zval *paddress TSRMLS_DC);
static char* _php_rfc822_write_address(ADDRESS *addresslist TSRMLS_DC);
static zend_string* _php_imap_parse_address(ADDRESS *addresslist, zval *paddress TSRMLS_DC);
static zend_string* _php_rfc822_write_address(ADDRESS *addresslist TSRMLS_DC);
/* the gets we use */
static char *php_mail_gets(readfn_t f, void *stream, unsigned long size, GETS_DATA *md);
@ -1482,7 +1482,7 @@ PHP_FUNCTION(imap_set_quota)
ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
limits.text.data = "STORAGE";
limits.text.data = (unsigned char*)"STORAGE";
limits.text.size = mailbox_size;
limits.next = NIL;
@ -1864,7 +1864,7 @@ PHP_FUNCTION(imap_list)
array_init(return_value);
cur=IMAPG(imap_folders);
while (cur != NIL) {
add_next_index_string(return_value, cur->LTEXT);
add_next_index_string(return_value, (char*)cur->LTEXT);
cur=cur->next;
}
mail_free_stringlist (&IMAPG(imap_folders));
@ -1905,7 +1905,7 @@ PHP_FUNCTION(imap_list_full)
cur=IMAPG(imap_folder_objects);
while (cur != NIL) {
object_init(&mboxob);
add_property_string(&mboxob, "name", cur->LTEXT);
add_property_string(&mboxob, "name", (char*)cur->LTEXT);
add_property_long(&mboxob, "attributes", cur->attributes);
#ifdef IMAP41
delim[0] = (char)cur->delimiter;
@ -1948,7 +1948,7 @@ PHP_FUNCTION(imap_listscan)
array_init(return_value);
cur=IMAPG(imap_folders);
while (cur != NIL) {
add_next_index_string(return_value, cur->LTEXT);
add_next_index_string(return_value, (char*)cur->LTEXT);
cur=cur->next;
}
mail_free_stringlist (&IMAPG(imap_folders));
@ -2170,7 +2170,7 @@ PHP_FUNCTION(imap_lsub)
array_init(return_value);
cur=IMAPG(imap_sfolders);
while (cur != NIL) {
add_next_index_string(return_value, cur->LTEXT);
add_next_index_string(return_value, (char*)cur->LTEXT);
cur=cur->next;
}
mail_free_stringlist (&IMAPG(imap_sfolders));
@ -2210,7 +2210,7 @@ PHP_FUNCTION(imap_lsub_full)
cur=IMAPG(imap_sfolder_objects);
while (cur != NIL) {
object_init(&mboxob);
add_property_string(&mboxob, "name", cur->LTEXT);
add_property_string(&mboxob, "name", (char*)cur->LTEXT);
add_property_long(&mboxob, "attributes", cur->attributes);
#ifdef IMAP41
delim[0] = (char)cur->delimiter;
@ -2535,7 +2535,7 @@ PHP_FUNCTION(imap_binary)
return;
}
decode = rfc822_binary(text, text_len, &newlength);
decode = (char*)rfc822_binary(text, text_len, &newlength);
if (decode == NULL) {
RETURN_FALSE;
@ -2600,7 +2600,7 @@ PHP_FUNCTION(imap_rfc822_write_address)
char *mailbox, *host, *personal;
int mailbox_len, host_len, personal_len;
ADDRESS *addr;
char *string;
zend_string *string;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", &mailbox, &mailbox_len, &host, &host_len, &personal, &personal_len) == FAILURE) {
return;
@ -2626,8 +2626,7 @@ PHP_FUNCTION(imap_rfc822_write_address)
string = _php_rfc822_write_address(addr TSRMLS_CC);
if (string) {
RETVAL_STRING(string);
efree(string);
RETVAL_STR(string);
} else {
RETURN_FALSE;
}
@ -2704,7 +2703,7 @@ PHP_FUNCTION(imap_utf8)
#else
utf8_mime2text(&src, &dest, U8T_DECOMPOSE);
#endif
RETVAL_STRINGL(dest.data, dest.size);
RETVAL_STRINGL((char*)dest.data, dest.size);
if (dest.data) {
free(dest.data);
}
@ -2869,7 +2868,7 @@ PHP_FUNCTION(imap_utf7_decode)
}
#endif
RETURN_STRINGL(out, outlen);
RETURN_STRINGL((char*)out, outlen);
}
/* }}} */
@ -2933,7 +2932,7 @@ PHP_FUNCTION(imap_utf7_encode)
out = STR_ALLOC(outlen, 0);
/* encode input string */
outp = out->val;
outp = (unsigned char*)out->val;
state = ST_NORMAL;
endp = (inp = in) + inlen;
while (inp < endp || state != ST_NORMAL) {
@ -3283,7 +3282,7 @@ PHP_FUNCTION(imap_bodystruct)
object_init(return_value);
body=mail_body(imap_le_struct->imap_stream, msg, section);
body=mail_body(imap_le_struct->imap_stream, msg, (unsigned char*)section);
if (body == NULL) {
zval_dtor(return_value);
RETURN_FALSE;
@ -3378,7 +3377,7 @@ PHP_FUNCTION(imap_fetch_overview)
int sequence_len;
pils *imap_le_struct;
zval myoverview;
char *address;
zend_string *address;
long status, flags = 0L;
int argc = ZEND_NUM_ARGS();
@ -3396,8 +3395,8 @@ PHP_FUNCTION(imap_fetch_overview)
array_init(return_value);
status = (flags & FT_UID)
? mail_uid_sequence(imap_le_struct->imap_stream, sequence)
: mail_sequence(imap_le_struct->imap_stream, sequence);
? mail_uid_sequence(imap_le_struct->imap_stream, (unsigned char*)sequence)
: mail_sequence(imap_le_struct->imap_stream, (unsigned char*)sequence);
if (status) {
MESSAGECACHE *elt;
@ -3415,22 +3414,18 @@ PHP_FUNCTION(imap_fetch_overview)
env->from->next=NULL;
address =_php_rfc822_write_address(env->from TSRMLS_CC);
if (address) {
// TODO: avoid reallocation ???
add_property_string(&myoverview, "from", address);
efree(address);
add_property_str(&myoverview, "from", address);
}
}
if (env->to) {
env->to->next = NULL;
address = _php_rfc822_write_address(env->to TSRMLS_CC);
if (address) {
// TODO: avoid reallocation ???
add_property_string(&myoverview, "to", address);
efree(address);
add_property_str(&myoverview, "to", address);
}
}
if (env->date) {
add_property_string(&myoverview, "date", env->date);
add_property_string(&myoverview, "date", (char*)env->date);
}
if (env->message_id) {
add_property_string(&myoverview, "message_id", env->message_id);
@ -3494,7 +3489,7 @@ PHP_FUNCTION(imap_mail_compose)
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(envelope), "date", sizeof("date") - 1)) != NULL) {
convert_to_string_ex(pvalue);
env->date = cpystr(Z_STRVAL_P(pvalue));
env->date = (unsigned char*)cpystr(Z_STRVAL_P(pvalue));
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(envelope), "from", sizeof("from") - 1)) != NULL) {
convert_to_string_ex(pvalue);
@ -3622,11 +3617,11 @@ PHP_FUNCTION(imap_mail_compose)
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "contents.data", sizeof("contents.data") - 1)) != NULL) {
convert_to_string_ex(pvalue);
bod->contents.text.data = (char *) fs_get(Z_STRLEN_P(pvalue) + 1);
bod->contents.text.data = fs_get(Z_STRLEN_P(pvalue) + 1);
memcpy(bod->contents.text.data, Z_STRVAL_P(pvalue), Z_STRLEN_P(pvalue)+1);
bod->contents.text.size = Z_STRLEN_P(pvalue);
} else {
bod->contents.text.data = (char *) fs_get(1);
bod->contents.text.data = fs_get(1);
memcpy(bod->contents.text.data, "", 1);
bod->contents.text.size = 0;
}
@ -3726,11 +3721,11 @@ PHP_FUNCTION(imap_mail_compose)
}
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "contents.data", sizeof("contents.data") - 1)) != NULL) {
convert_to_string_ex(pvalue);
bod->contents.text.data = (char *) fs_get(Z_STRLEN_P(pvalue) + 1);
bod->contents.text.data = fs_get(Z_STRLEN_P(pvalue) + 1);
memcpy(bod->contents.text.data, Z_STRVAL_P(pvalue), Z_STRLEN_P(pvalue) + 1);
bod->contents.text.size = Z_STRLEN_P(pvalue);
} else {
bod->contents.text.data = (char *) fs_get(1);
bod->contents.text.data = fs_get(1);
memcpy(bod->contents.text.data, "", 1);
bod->contents.text.size = 0;
}
@ -4133,7 +4128,7 @@ PHP_FUNCTION(imap_alerts)
cur = IMAPG(imap_alertstack);
while (cur != NIL) {
add_next_index_string(return_value, cur->LTEXT);
add_next_index_string(return_value, (char*)cur->LTEXT);
cur = cur->next;
}
mail_free_stringlist(&IMAPG(imap_alertstack));
@ -4160,7 +4155,7 @@ PHP_FUNCTION(imap_errors)
cur = IMAPG(imap_errorstack);
while (cur != NIL) {
add_next_index_string(return_value, cur->LTEXT);
add_next_index_string(return_value, (char*)cur->LTEXT);
cur = cur->next;
}
mail_free_errorlist(&IMAPG(imap_errorstack));
@ -4186,7 +4181,7 @@ PHP_FUNCTION(imap_last_error)
cur = IMAPG(imap_errorstack);
while (cur != NIL) {
if (cur->next == NIL) {
RETURN_STRING(cur->LTEXT);
RETURN_STRING((char*)cur->LTEXT);
}
cur = cur->next;
}
@ -4305,10 +4300,9 @@ static long _php_rfc822_soutr (void *stream, char *string)
/* {{{ _php_rfc822_write_address
*/
static char* _php_rfc822_write_address(ADDRESS *addresslist TSRMLS_DC)
static zend_string* _php_rfc822_write_address(ADDRESS *addresslist TSRMLS_DC)
{
char address[MAILTMPLEN];
char *str;
smart_str ret = {0};
RFC822BUFFER buf;
@ -4320,11 +4314,7 @@ static char* _php_rfc822_write_address(ADDRESS *addresslist TSRMLS_DC)
rfc822_output_address_list(&buf, addresslist, 0, NULL);
rfc822_output_flush(&buf);
smart_str_0(&ret);
/* avoide dup? */
str = estrndup(ret.s->val, ret.s->len);
smart_str_free(&ret);
return str;
return ret.s;
}
/* }}} */
@ -4390,7 +4380,7 @@ static int _php_imap_address_size (ADDRESS *addresslist)
/* {{{ _php_rfc822_write_address
*/
static char* _php_rfc822_write_address(ADDRESS *addresslist TSRMLS_DC)
static zend_string* _php_rfc822_write_address(ADDRESS *addresslist TSRMLS_DC)
{
char address[SENDBUFLEN];
@ -4400,15 +4390,15 @@ static char* _php_rfc822_write_address(ADDRESS *addresslist TSRMLS_DC)
}
address[0] = 0;
rfc822_write_address(address, addresslist);
return estrdup(address);
return STR_INIT(address, strlen(address), 0);
}
/* }}} */
#endif
/* {{{ _php_imap_parse_address
*/
static char* _php_imap_parse_address (ADDRESS *addresslist, zval *paddress TSRMLS_DC)
static zend_string* _php_imap_parse_address (ADDRESS *addresslist, zval *paddress TSRMLS_DC)
{
char *fulladdress;
zend_string *fulladdress;
ADDRESS *addresstmp;
zval tmpvals;
@ -4434,13 +4424,13 @@ static char* _php_imap_parse_address (ADDRESS *addresslist, zval *paddress TSRML
static void _php_make_header_object(zval *myzvalue, ENVELOPE *en TSRMLS_DC)
{
zval paddress;
char *fulladdress=NULL;
zend_string *fulladdress=NULL;
object_init(myzvalue);
if (en->remail) add_property_string(myzvalue, "remail", en->remail);
if (en->date) add_property_string(myzvalue, "date", en->date);
if (en->date) add_property_string(myzvalue, "Date", en->date);
if (en->date) add_property_string(myzvalue, "date", (char*)en->date);
if (en->date) add_property_string(myzvalue, "Date", (char*)en->date);
if (en->subject) add_property_string(myzvalue, "subject", en->subject);
if (en->subject) add_property_string(myzvalue, "Subject", en->subject);
if (en->in_reply_to) add_property_string(myzvalue, "in_reply_to", en->in_reply_to);
@ -4453,9 +4443,7 @@ static void _php_make_header_object(zval *myzvalue, ENVELOPE *en TSRMLS_DC)
array_init(&paddress);
fulladdress = _php_imap_parse_address(en->to, &paddress TSRMLS_CC);
if (fulladdress) {
// TODO: avoid reallocation ???
add_property_string(myzvalue, "toaddress", fulladdress);
efree(fulladdress);
add_property_str(myzvalue, "toaddress", fulladdress);
}
add_assoc_object(myzvalue, "to", &paddress TSRMLS_CC);
}
@ -4464,9 +4452,7 @@ static void _php_make_header_object(zval *myzvalue, ENVELOPE *en TSRMLS_DC)
array_init(&paddress);
fulladdress = _php_imap_parse_address(en->from, &paddress TSRMLS_CC);
if (fulladdress) {
// TODO: avoid reallocation ???
add_property_string(myzvalue, "fromaddress", fulladdress);
efree(fulladdress);
add_property_str(myzvalue, "fromaddress", fulladdress);
}
add_assoc_object(myzvalue, "from", &paddress TSRMLS_CC);
}
@ -4475,9 +4461,7 @@ static void _php_make_header_object(zval *myzvalue, ENVELOPE *en TSRMLS_DC)
array_init(&paddress);
fulladdress = _php_imap_parse_address(en->cc, &paddress TSRMLS_CC);
if (fulladdress) {
// TODO: avoid reallocation ???
add_property_string(myzvalue, "ccaddress", fulladdress);
efree(fulladdress);
add_property_str(myzvalue, "ccaddress", fulladdress);
}
add_assoc_object(myzvalue, "cc", &paddress TSRMLS_CC);
}
@ -4486,9 +4470,7 @@ static void _php_make_header_object(zval *myzvalue, ENVELOPE *en TSRMLS_DC)
array_init(&paddress);
fulladdress = _php_imap_parse_address(en->bcc, &paddress TSRMLS_CC);
if (fulladdress) {
// TODO: avoid reallocation ???
add_property_string(myzvalue, "bccaddress", fulladdress);
efree(fulladdress);
add_property_str(myzvalue, "bccaddress", fulladdress);
}
add_assoc_object(myzvalue, "bcc", &paddress TSRMLS_CC);
}
@ -4497,9 +4479,7 @@ static void _php_make_header_object(zval *myzvalue, ENVELOPE *en TSRMLS_DC)
array_init(&paddress);
fulladdress = _php_imap_parse_address(en->reply_to, &paddress TSRMLS_CC);
if (fulladdress) {
// TODO: avoid reallocation ???
add_property_string(myzvalue, "reply_toaddress", fulladdress);
efree(fulladdress);
add_property_str(myzvalue, "reply_toaddress", fulladdress);
}
add_assoc_object(myzvalue, "reply_to", &paddress TSRMLS_CC);
}
@ -4508,9 +4488,7 @@ static void _php_make_header_object(zval *myzvalue, ENVELOPE *en TSRMLS_DC)
array_init(&paddress);
fulladdress = _php_imap_parse_address(en->sender, &paddress TSRMLS_CC);
if (fulladdress) {
// TODO: avoid reallocation ???
add_property_string(myzvalue, "senderaddress", fulladdress);
efree(fulladdress);
add_property_str(myzvalue, "senderaddress", fulladdress);
}
add_assoc_object(myzvalue, "sender", &paddress TSRMLS_CC);
}
@ -4519,9 +4497,7 @@ static void _php_make_header_object(zval *myzvalue, ENVELOPE *en TSRMLS_DC)
array_init(&paddress);
fulladdress = _php_imap_parse_address(en->return_path, &paddress TSRMLS_CC);
if (fulladdress) {
// TODO: avoid reallocation ???
add_property_string(myzvalue, "return_pathaddress", fulladdress);
efree(fulladdress);
add_property_str(myzvalue, "return_pathaddress", fulladdress);
}
add_assoc_object(myzvalue, "return_path", &paddress TSRMLS_CC);
}
@ -4873,7 +4849,7 @@ PHP_IMAP_EXPORT void mm_notify(MAILSTREAM *stream, char *str, long errflg)
if (strncmp(str, "[ALERT] ", 8) == 0) {
if (IMAPG(imap_alertstack) == NIL) {
IMAPG(imap_alertstack) = mail_newstringlist();
IMAPG(imap_alertstack)->LSIZE = strlen(IMAPG(imap_alertstack)->LTEXT = cpystr(str));
IMAPG(imap_alertstack)->LSIZE = strlen((char*)(IMAPG(imap_alertstack)->LTEXT = (unsigned char*)cpystr(str)));
IMAPG(imap_alertstack)->next = NIL;
} else {
cur = IMAPG(imap_alertstack);
@ -4882,7 +4858,7 @@ PHP_IMAP_EXPORT void mm_notify(MAILSTREAM *stream, char *str, long errflg)
}
cur->next = mail_newstringlist ();
cur = cur->next;
cur->LSIZE = strlen(cur->LTEXT = cpystr(str));
cur->LSIZE = strlen((char*)(cur->LTEXT = (unsigned char*)cpystr(str)));
cur->next = NIL;
}
}
@ -4899,7 +4875,7 @@ PHP_IMAP_EXPORT void mm_list(MAILSTREAM *stream, DTYPE delimiter, char *mailbox,
/* Author: CJH */
if (IMAPG(imap_folder_objects) == NIL) {
IMAPG(imap_folder_objects) = mail_newfolderobjectlist();
IMAPG(imap_folder_objects)->LSIZE=strlen(IMAPG(imap_folder_objects)->LTEXT=cpystr(mailbox));
IMAPG(imap_folder_objects)->LSIZE=strlen((char*)(IMAPG(imap_folder_objects)->LTEXT = (unsigned char*)cpystr(mailbox)));
IMAPG(imap_folder_objects)->delimiter = delimiter;
IMAPG(imap_folder_objects)->attributes = attributes;
IMAPG(imap_folder_objects)->next = NIL;
@ -4908,7 +4884,7 @@ PHP_IMAP_EXPORT void mm_list(MAILSTREAM *stream, DTYPE delimiter, char *mailbox,
ocur=IMAPG(imap_folder_objects_tail);
ocur->next=mail_newfolderobjectlist();
ocur=ocur->next;
ocur->LSIZE = strlen(ocur->LTEXT = cpystr(mailbox));
ocur->LSIZE = strlen((char*)(ocur->LTEXT = (unsigned char*)cpystr(mailbox)));
ocur->delimiter = delimiter;
ocur->attributes = attributes;
ocur->next = NIL;
@ -4920,14 +4896,14 @@ PHP_IMAP_EXPORT void mm_list(MAILSTREAM *stream, DTYPE delimiter, char *mailbox,
if (!(attributes & LATT_NOSELECT)) {
if (IMAPG(imap_folders) == NIL) {
IMAPG(imap_folders)=mail_newstringlist();
IMAPG(imap_folders)->LSIZE=strlen(IMAPG(imap_folders)->LTEXT=cpystr(mailbox));
IMAPG(imap_folders)->LSIZE=strlen((char*)(IMAPG(imap_folders)->LTEXT = (unsigned char*)cpystr(mailbox)));
IMAPG(imap_folders)->next=NIL;
IMAPG(imap_folders_tail) = IMAPG(imap_folders);
} else {
cur=IMAPG(imap_folders_tail);
cur->next=mail_newstringlist ();
cur=cur->next;
cur->LSIZE = strlen (cur->LTEXT = cpystr (mailbox));
cur->LSIZE = strlen((char*)(cur->LTEXT = (unsigned char*)cpystr(mailbox)));
cur->next = NIL;
IMAPG(imap_folders_tail) = cur;
}
@ -4946,7 +4922,7 @@ PHP_IMAP_EXPORT void mm_lsub(MAILSTREAM *stream, DTYPE delimiter, char *mailbox,
/* Author: CJH */
if (IMAPG(imap_sfolder_objects) == NIL) {
IMAPG(imap_sfolder_objects) = mail_newfolderobjectlist();
IMAPG(imap_sfolder_objects)->LSIZE=strlen(IMAPG(imap_sfolder_objects)->LTEXT=cpystr(mailbox));
IMAPG(imap_sfolder_objects)->LSIZE = strlen((char*)(IMAPG(imap_sfolder_objects)->LTEXT = (unsigned char*)cpystr(mailbox)));
IMAPG(imap_sfolder_objects)->delimiter = delimiter;
IMAPG(imap_sfolder_objects)->attributes = attributes;
IMAPG(imap_sfolder_objects)->next = NIL;
@ -4955,7 +4931,7 @@ PHP_IMAP_EXPORT void mm_lsub(MAILSTREAM *stream, DTYPE delimiter, char *mailbox,
ocur=IMAPG(imap_sfolder_objects_tail);
ocur->next=mail_newfolderobjectlist();
ocur=ocur->next;
ocur->LSIZE=strlen(ocur->LTEXT = cpystr(mailbox));
ocur->LSIZE=strlen((char*)(ocur->LTEXT = (unsigned char*)cpystr(mailbox)));
ocur->delimiter = delimiter;
ocur->attributes = attributes;
ocur->next = NIL;
@ -4965,14 +4941,14 @@ PHP_IMAP_EXPORT void mm_lsub(MAILSTREAM *stream, DTYPE delimiter, char *mailbox,
/* build the old simple array for imap_listsubscribed() */
if (IMAPG(imap_sfolders) == NIL) {
IMAPG(imap_sfolders)=mail_newstringlist();
IMAPG(imap_sfolders)->LSIZE=strlen(IMAPG(imap_sfolders)->LTEXT=cpystr(mailbox));
IMAPG(imap_sfolders)->LSIZE=strlen((char*)(IMAPG(imap_sfolders)->LTEXT = (unsigned char*)cpystr(mailbox)));
IMAPG(imap_sfolders)->next=NIL;
IMAPG(imap_sfolders_tail) = IMAPG(imap_sfolders);
} else {
cur=IMAPG(imap_sfolders_tail);
cur->next=mail_newstringlist ();
cur=cur->next;
cur->LSIZE = strlen (cur->LTEXT = cpystr (mailbox));
cur->LSIZE = strlen((char*)(cur->LTEXT = (unsigned char*)cpystr(mailbox)));
cur->next = NIL;
IMAPG(imap_sfolders_tail) = cur;
}
@ -5010,7 +4986,7 @@ PHP_IMAP_EXPORT void mm_log(char *str, long errflg)
if (errflg != NIL) { /* CJH: maybe put these into a more comprehensive log for debugging purposes? */
if (IMAPG(imap_errorstack) == NIL) {
IMAPG(imap_errorstack) = mail_newerrorlist();
IMAPG(imap_errorstack)->LSIZE = strlen(IMAPG(imap_errorstack)->LTEXT = cpystr(str));
IMAPG(imap_errorstack)->LSIZE = strlen((char*)(IMAPG(imap_errorstack)->LTEXT = (unsigned char*)cpystr(str)));
IMAPG(imap_errorstack)->errflg = errflg;
IMAPG(imap_errorstack)->next = NIL;
} else {
@ -5020,7 +4996,7 @@ PHP_IMAP_EXPORT void mm_log(char *str, long errflg)
}
cur->next = mail_newerrorlist();
cur = cur->next;
cur->LSIZE = strlen(cur->LTEXT = cpystr(str));
cur->LSIZE = strlen((char*)(cur->LTEXT = (unsigned char*)cpystr(str)));
cur->errflg = errflg;
cur->next = NIL;
}

View File

@ -1760,31 +1760,30 @@ PHP_FUNCTION(openssl_x509_export)
}
/* }}} */
int php_openssl_x509_fingerprint(X509 *peer, const char *method, zend_bool raw, char **out, int *out_len TSRMLS_DC)
zend_string* php_openssl_x509_fingerprint(X509 *peer, const char *method, zend_bool raw TSRMLS_DC)
{
unsigned char md[EVP_MAX_MD_SIZE];
const EVP_MD *mdtype;
unsigned int n;
zend_string *ret;
if (!(mdtype = EVP_get_digestbyname(method))) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown signature algorithm");
return FAILURE;
return NULL;
} else if (!X509_digest(peer, mdtype, md, &n)) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not generate signature");
return FAILURE;
return NULL;
}
if (raw) {
*out_len = n;
*out = estrndup((char *) md, n);
ret = STR_INIT((char*)md, n, 0);
} else {
*out_len = n * 2;
*out = emalloc(*out_len + 1);
make_digest_ex(*out, md, n);
ret = STR_ALLOC(n * 2, 0);
make_digest_ex(ret->val, md, n);
ret->val[n * 2] = '\0';
}
return SUCCESS;
return ret;
}
PHP_FUNCTION(openssl_x509_fingerprint)
@ -1795,9 +1794,7 @@ PHP_FUNCTION(openssl_x509_fingerprint)
zend_bool raw_output = 0;
char *method = "sha1";
int method_len;
char *fingerprint;
int fingerprint_len;
zend_string *fingerprint;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|sb", &zcert, &method, &method_len, &raw_output) == FAILURE) {
return;
@ -1809,10 +1806,9 @@ PHP_FUNCTION(openssl_x509_fingerprint)
RETURN_FALSE;
}
if (php_openssl_x509_fingerprint(cert, method, raw_output, &fingerprint, &fingerprint_len TSRMLS_CC) == SUCCESS) {
// TODO: avoid reallocation ???
RETVAL_STRINGL(fingerprint, fingerprint_len);
efree(fingerprint);
fingerprint = php_openssl_x509_fingerprint(cert, method, raw_output TSRMLS_CC);
if (fingerprint) {
RETVAL_STR(fingerprint);
} else {
RETVAL_FALSE;
}
@ -3458,12 +3454,10 @@ static int php_openssl_is_private_key(EVP_PKEY* pkey TSRMLS_DC)
#define OPENSSL_PKEY_GET_BN(_type, _name) do { \
if (pkey->pkey._type->_name != NULL) { \
int len = BN_num_bytes(pkey->pkey._type->_name); \
char *str = emalloc(len + 1); \
BN_bn2bin(pkey->pkey._type->_name, (unsigned char*)str); \
str[len] = 0; \
/* TODO: avoid reallocation ??? */ \
add_assoc_stringl(&_type, #_name, str, len); \
efree(str); \
zend_string *str = STR_ALLOC(len, 0); \
BN_bn2bin(pkey->pkey._type->_name, (unsigned char*)str->val); \
str->val[len] = 0; \
add_assoc_str(&_type, #_name, str); \
} \
} while (0)
@ -3877,7 +3871,7 @@ PHP_FUNCTION(openssl_pbkdf2)
char *password; int password_len;
char *salt; int salt_len;
char *method; int method_len = 0;
unsigned char *out_buffer;
zend_string *out_buffer;
const EVP_MD *digest;
@ -3904,15 +3898,13 @@ PHP_FUNCTION(openssl_pbkdf2)
RETURN_FALSE;
}
out_buffer = emalloc(key_length + 1);
out_buffer[key_length] = '\0';
out_buffer = STR_ALLOC(key_length, 0);
if (PKCS5_PBKDF2_HMAC(password, password_len, (unsigned char *)salt, salt_len, iterations, digest, key_length, out_buffer) == 1) {
// TODO: avoid reallocation ???
RETVAL_STRINGL((char *)out_buffer, key_length);
efree(out_buffer);
if (PKCS5_PBKDF2_HMAC(password, password_len, (unsigned char *)salt, salt_len, iterations, digest, key_length, (unsigned char*)out_buffer->val) == 1) {
out_buffer->val[key_length] = 0;
RETURN_STR(out_buffer);
} else {
efree(out_buffer);
STR_RELEASE(out_buffer);
RETURN_FALSE;
}
}
@ -4336,7 +4328,7 @@ PHP_FUNCTION(openssl_private_encrypt)
zval *key, *crypted;
EVP_PKEY *pkey;
int cryptedlen;
unsigned char *cryptedbuf = NULL;
zend_string *cryptedbuf = NULL;
int successful = 0;
zend_resource *keyresource = NULL;
char * data;
@ -4356,14 +4348,14 @@ PHP_FUNCTION(openssl_private_encrypt)
}
cryptedlen = EVP_PKEY_size(pkey);
cryptedbuf = emalloc(cryptedlen + 1);
cryptedbuf = STR_ALLOC(cryptedlen, 0);
switch (pkey->type) {
case EVP_PKEY_RSA:
case EVP_PKEY_RSA2:
successful = (RSA_private_encrypt(data_len,
(unsigned char *)data,
cryptedbuf,
(unsigned char *)cryptedbuf->val,
pkey->pkey.rsa,
padding) == cryptedlen);
break;
@ -4373,15 +4365,13 @@ PHP_FUNCTION(openssl_private_encrypt)
if (successful) {
zval_dtor(crypted);
cryptedbuf[cryptedlen] = '\0';
// TODO: avoid reallocation ???
ZVAL_STRINGL(crypted, (char *)cryptedbuf, cryptedlen);
efree(cryptedbuf);
cryptedbuf->val[cryptedlen] = '\0';
ZVAL_STR(crypted, cryptedbuf);
cryptedbuf = NULL;
RETVAL_TRUE;
}
if (cryptedbuf) {
efree(cryptedbuf);
STR_RELEASE(cryptedbuf);
}
if (keyresource == NULL) {
EVP_PKEY_free(pkey);
@ -4396,7 +4386,7 @@ PHP_FUNCTION(openssl_private_decrypt)
zval *key, *crypted;
EVP_PKEY *pkey;
int cryptedlen;
unsigned char *cryptedbuf = NULL;
zend_string *cryptedbuf = NULL;
unsigned char *crypttemp;
int successful = 0;
long padding = RSA_PKCS1_PADDING;
@ -4427,8 +4417,8 @@ PHP_FUNCTION(openssl_private_decrypt)
pkey->pkey.rsa,
padding);
if (cryptedlen != -1) {
cryptedbuf = emalloc(cryptedlen + 1);
memcpy(cryptedbuf, crypttemp, cryptedlen);
cryptedbuf = STR_ALLOC(cryptedlen, 0);
memcpy(cryptedbuf->val, crypttemp, cryptedlen);
successful = 1;
}
break;
@ -4440,10 +4430,8 @@ PHP_FUNCTION(openssl_private_decrypt)
if (successful) {
zval_dtor(crypted);
cryptedbuf[cryptedlen] = '\0';
// TODO: avoid reallocation ???
ZVAL_STRINGL(crypted, (char *)cryptedbuf, cryptedlen);
efree(cryptedbuf);
cryptedbuf->val[cryptedlen] = '\0';
ZVAL_STR(crypted, cryptedbuf);
cryptedbuf = NULL;
RETVAL_TRUE;
}
@ -4452,7 +4440,7 @@ PHP_FUNCTION(openssl_private_decrypt)
EVP_PKEY_free(pkey);
}
if (cryptedbuf) {
efree(cryptedbuf);
STR_RELEASE(cryptedbuf);
}
}
/* }}} */
@ -4464,7 +4452,7 @@ PHP_FUNCTION(openssl_public_encrypt)
zval *key, *crypted;
EVP_PKEY *pkey;
int cryptedlen;
unsigned char *cryptedbuf;
zend_string *cryptedbuf;
int successful = 0;
zend_resource *keyresource = NULL;
long padding = RSA_PKCS1_PADDING;
@ -4482,14 +4470,14 @@ PHP_FUNCTION(openssl_public_encrypt)
}
cryptedlen = EVP_PKEY_size(pkey);
cryptedbuf = emalloc(cryptedlen + 1);
cryptedbuf = STR_ALLOC(cryptedlen, 0);
switch (pkey->type) {
case EVP_PKEY_RSA:
case EVP_PKEY_RSA2:
successful = (RSA_public_encrypt(data_len,
(unsigned char *)data,
cryptedbuf,
(unsigned char *)cryptedbuf->val,
pkey->pkey.rsa,
padding) == cryptedlen);
break;
@ -4500,10 +4488,8 @@ PHP_FUNCTION(openssl_public_encrypt)
if (successful) {
zval_dtor(crypted);
cryptedbuf[cryptedlen] = '\0';
// TODO: avoid reallocation ???
ZVAL_STRINGL(crypted, (char *)cryptedbuf, cryptedlen);
efree(cryptedbuf);
cryptedbuf->val[cryptedlen] = '\0';
ZVAL_STR(crypted, cryptedbuf);
cryptedbuf = NULL;
RETVAL_TRUE;
}
@ -4511,7 +4497,7 @@ PHP_FUNCTION(openssl_public_encrypt)
EVP_PKEY_free(pkey);
}
if (cryptedbuf) {
efree(cryptedbuf);
STR_RELEASE(cryptedbuf);
}
}
/* }}} */
@ -4523,7 +4509,7 @@ PHP_FUNCTION(openssl_public_decrypt)
zval *key, *crypted;
EVP_PKEY *pkey;
int cryptedlen;
unsigned char *cryptedbuf = NULL;
zend_string *cryptedbuf = NULL;
unsigned char *crypttemp;
int successful = 0;
zend_resource *keyresource = NULL;
@ -4554,8 +4540,8 @@ PHP_FUNCTION(openssl_public_decrypt)
pkey->pkey.rsa,
padding);
if (cryptedlen != -1) {
cryptedbuf = emalloc(cryptedlen + 1);
memcpy(cryptedbuf, crypttemp, cryptedlen);
cryptedbuf = STR_ALLOC(cryptedlen, 0);
memcpy(cryptedbuf->val, crypttemp, cryptedlen);
successful = 1;
}
break;
@ -4569,16 +4555,14 @@ PHP_FUNCTION(openssl_public_decrypt)
if (successful) {
zval_dtor(crypted);
cryptedbuf[cryptedlen] = '\0';
// TODO: avoid reallocation ???
ZVAL_STRINGL(crypted, (char *)cryptedbuf, cryptedlen);
efree(cryptedbuf);
cryptedbuf->val[cryptedlen] = '\0';
ZVAL_STR(crypted, cryptedbuf);
cryptedbuf = NULL;
RETVAL_TRUE;
}
if (cryptedbuf) {
efree(cryptedbuf);
STR_RELEASE(cryptedbuf);
}
if (keyresource == NULL) {
EVP_PKEY_free(pkey);
@ -4612,8 +4596,8 @@ PHP_FUNCTION(openssl_sign)
{
zval *key, *signature;
EVP_PKEY *pkey;
int siglen;
unsigned char *sigbuf;
unsigned int siglen;
zend_string *sigbuf;
zend_resource *keyresource = NULL;
char * data;
int data_len;
@ -4648,16 +4632,15 @@ PHP_FUNCTION(openssl_sign)
}
siglen = EVP_PKEY_size(pkey);
sigbuf = emalloc(siglen + 1);
sigbuf = STR_ALLOC(siglen, 0);
EVP_SignInit(&md_ctx, mdtype);
EVP_SignUpdate(&md_ctx, data, data_len);
if (EVP_SignFinal (&md_ctx, sigbuf,(unsigned int *)&siglen, pkey)) {
if (EVP_SignFinal (&md_ctx, (unsigned char*)sigbuf->val, &siglen, pkey)) {
zval_dtor(signature);
sigbuf[siglen] = '\0';
// TODO: avoid reallocation ???
ZVAL_STRINGL(signature, (char *)sigbuf, siglen);
efree(sigbuf);
sigbuf->val[siglen] = '\0';
sigbuf->len = siglen;
ZVAL_STR(signature, sigbuf);
RETVAL_TRUE;
} else {
efree(sigbuf);
@ -4965,8 +4948,8 @@ PHP_FUNCTION(openssl_digest)
int data_len, method_len;
const EVP_MD *mdtype;
EVP_MD_CTX md_ctx;
int siglen;
unsigned char *sigbuf;
unsigned int siglen;
zend_string *sigbuf;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", &data, &data_len, &method, &method_len, &raw_output) == FAILURE) {
return;
@ -4978,28 +4961,26 @@ PHP_FUNCTION(openssl_digest)
}
siglen = EVP_MD_size(mdtype);
sigbuf = emalloc(siglen + 1);
sigbuf = STR_ALLOC(siglen, 0);
EVP_DigestInit(&md_ctx, mdtype);
EVP_DigestUpdate(&md_ctx, (unsigned char *)data, data_len);
if (EVP_DigestFinal (&md_ctx, (unsigned char *)sigbuf, (unsigned int *)&siglen)) {
if (EVP_DigestFinal (&md_ctx, (unsigned char *)sigbuf->val, &siglen)) {
if (raw_output) {
sigbuf[siglen] = '\0';
// TODO: avoid reallocation ???
RETVAL_STRINGL((char *)sigbuf, siglen);
efree(sigbuf);
sigbuf->val[siglen] = '\0';
sigbuf->len = siglen;
RETVAL_STR(sigbuf);
} else {
int digest_str_len = siglen * 2;
char *digest_str = emalloc(digest_str_len + 1);
zend_string *digest_str = STR_ALLOC(digest_str_len, 0);
make_digest_ex(digest_str, sigbuf, siglen);
efree(sigbuf);
// TODO: avid reallocation ???
RETVAL_STRINGL(digest_str, digest_str_len);
efree(digest_str);
make_digest_ex(digest_str->val, (unsigned char*)sigbuf->val, siglen);
digest_str->val[digest_str_len] = '\0';
STR_RELEASE(sigbuf);
RETVAL_STR(digest_str);
}
} else {
efree(sigbuf);
STR_RELEASE(sigbuf);
RETVAL_FALSE;
}
}
@ -5049,7 +5030,8 @@ PHP_FUNCTION(openssl_encrypt)
const EVP_CIPHER *cipher_type;
EVP_CIPHER_CTX cipher_ctx;
int i=0, outlen, keylen;
unsigned char *outbuf, *key;
zend_string *outbuf;
unsigned char *key;
zend_bool free_iv;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|ls", &data, &data_len, &method, &method_len, &password, &password_len, &options, &iv, &iv_len) == FAILURE) {
@ -5077,7 +5059,7 @@ PHP_FUNCTION(openssl_encrypt)
free_iv = php_openssl_validate_iv(&iv, &iv_len, max_iv_len TSRMLS_CC);
outlen = data_len + EVP_CIPHER_block_size(cipher_type);
outbuf = emalloc(outlen + 1);
outbuf = STR_ALLOC(outlen, 0);
EVP_EncryptInit(&cipher_ctx, cipher_type, NULL, NULL);
if (password_len > keylen) {
@ -5088,25 +5070,24 @@ PHP_FUNCTION(openssl_encrypt)
EVP_CIPHER_CTX_set_padding(&cipher_ctx, 0);
}
if (data_len > 0) {
EVP_EncryptUpdate(&cipher_ctx, outbuf, &i, (unsigned char *)data, data_len);
EVP_EncryptUpdate(&cipher_ctx, (unsigned char*)outbuf->val, &i, (unsigned char *)data, data_len);
}
outlen = i;
if (EVP_EncryptFinal(&cipher_ctx, (unsigned char *)outbuf + i, &i)) {
if (EVP_EncryptFinal(&cipher_ctx, (unsigned char *)outbuf->val + i, &i)) {
outlen += i;
if (options & OPENSSL_RAW_DATA) {
outbuf[outlen] = '\0';
// TODO: avoid reallocation ???
RETVAL_STRINGL((char *)outbuf, outlen);
efree(outbuf);
outbuf->val[outlen] = '\0';
outbuf->len = outlen;
RETVAL_STR(outbuf);
} else {
zend_string *base64_str;
base64_str = php_base64_encode(outbuf, outlen);
efree(outbuf);
base64_str = php_base64_encode((unsigned char*)outbuf->val, outlen);
STR_RELEASE(outbuf);
RETVAL_STR(base64_str);
}
} else {
efree(outbuf);
STR_RELEASE(outbuf);
RETVAL_FALSE;
}
if (key != (unsigned char*)password) {
@ -5129,7 +5110,8 @@ PHP_FUNCTION(openssl_decrypt)
const EVP_CIPHER *cipher_type;
EVP_CIPHER_CTX cipher_ctx;
int i, outlen, keylen;
unsigned char *outbuf, *key;
zend_string *outbuf;
unsigned char *key;
zend_string *base64_str = NULL;
zend_bool free_iv;
@ -5170,7 +5152,7 @@ PHP_FUNCTION(openssl_decrypt)
free_iv = php_openssl_validate_iv(&iv, &iv_len, EVP_CIPHER_iv_length(cipher_type) TSRMLS_CC);
outlen = data_len + EVP_CIPHER_block_size(cipher_type);
outbuf = emalloc(outlen + 1);
outbuf = STR_ALLOC(outlen, 0);
EVP_DecryptInit(&cipher_ctx, cipher_type, NULL, NULL);
if (password_len > keylen) {
@ -5180,16 +5162,15 @@ PHP_FUNCTION(openssl_decrypt)
if (options & OPENSSL_ZERO_PADDING) {
EVP_CIPHER_CTX_set_padding(&cipher_ctx, 0);
}
EVP_DecryptUpdate(&cipher_ctx, outbuf, &i, (unsigned char *)data, data_len);
EVP_DecryptUpdate(&cipher_ctx, (unsigned char*)outbuf->val, &i, (unsigned char *)data, data_len);
outlen = i;
if (EVP_DecryptFinal(&cipher_ctx, (unsigned char *)outbuf + i, &i)) {
if (EVP_DecryptFinal(&cipher_ctx, (unsigned char *)outbuf->val + i, &i)) {
outlen += i;
outbuf[outlen] = '\0';
// TODO: avoid reallocation ???
RETVAL_STRINGL((char *)outbuf, outlen);
efree(outbuf);
outbuf->val[outlen] = '\0';
outbuf->len = outlen;
RETVAL_STR(outbuf);
} else {
efree(outbuf);
STR_RELEASE(outbuf);
RETVAL_FALSE;
}
if (key != (unsigned char*)password) {
@ -5241,7 +5222,7 @@ PHP_FUNCTION(openssl_dh_compute_key)
int pub_len;
EVP_PKEY *pkey;
BIGNUM *pub;
char *data;
zend_string *data;
int len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sr", &pub_str, &pub_len, &key) == FAILURE) {
@ -5254,16 +5235,15 @@ PHP_FUNCTION(openssl_dh_compute_key)
pub = BN_bin2bn((unsigned char*)pub_str, pub_len, NULL);
data = emalloc(DH_size(pkey->pkey.dh) + 1);
len = DH_compute_key((unsigned char*)data, pub, pkey->pkey.dh);
data = STR_ALLOC(DH_size(pkey->pkey.dh), 0);
len = DH_compute_key((unsigned char*)data->val, pub, pkey->pkey.dh);
if (len >= 0) {
data[len] = 0;
// TODO: avoid reallocation ???
RETVAL_STRINGL(data, len);
efree(data);
data->len = len;
data->val[len] = 0;
RETVAL_STR(data);
} else {
efree(data);
STR_RELEASE(data);
RETVAL_FALSE;
}
@ -5276,7 +5256,7 @@ PHP_FUNCTION(openssl_dh_compute_key)
PHP_FUNCTION(openssl_random_pseudo_bytes)
{
long buffer_length;
unsigned char *buffer = NULL;
zend_string *buffer = NULL;
zval *zstrong_result_returned = NULL;
int strong_result = 0;
@ -5293,21 +5273,21 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
ZVAL_BOOL(zstrong_result_returned, 0);
}
buffer = emalloc(buffer_length + 1);
buffer = STR_ALLOC(buffer_length, 0);
#ifdef PHP_WIN32
strong_result = 1;
/* random/urandom equivalent on Windows */
if (php_win32_get_random_bytes(buffer, (size_t) buffer_length) == FAILURE){
efree(buffer);
if (php_win32_get_random_bytes((unsigned char*)buffer->val, (size_t) buffer_length) == FAILURE){
STR_RELEASE(buffer);
if (zstrong_result_returned) {
ZVAL_BOOL(zstrong_result_returned, 0);
}
RETURN_FALSE;
}
#else
if ((strong_result = RAND_pseudo_bytes(buffer, buffer_length)) < 0) {
efree(buffer);
if ((strong_result = RAND_pseudo_bytes((unsigned char*)buffer->val, buffer_length)) < 0) {
STR_RELEASE(buffer);
if (zstrong_result_returned) {
ZVAL_BOOL(zstrong_result_returned, 0);
}
@ -5315,10 +5295,8 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
}
#endif
buffer[buffer_length] = 0;
// TODO: avoid reallocation ???
RETVAL_STRINGL((char *)buffer, buffer_length);
efree(buffer);
buffer->val[buffer_length] = 0;
RETVAL_STR(buffer);
if (zstrong_result_returned) {
ZVAL_BOOL(zstrong_result_returned, strong_result);

View File

@ -75,7 +75,7 @@
#define PHP_X509_NAME_ENTRY_TO_UTF8(ne, i, out) ASN1_STRING_to_UTF8(&out, X509_NAME_ENTRY_get_data(X509_NAME_get_entry(ne, i)))
extern php_stream* php_openssl_get_stream_from_ssl_handle(const SSL *ssl);
extern int php_openssl_x509_fingerprint(X509 *peer, const char *method, zend_bool raw, char **out, int *out_len TSRMLS_DC);
extern zend_string* php_openssl_x509_fingerprint(X509 *peer, const char *method, zend_bool raw TSRMLS_DC);
extern int php_openssl_get_ssl_stream_data_index();
extern int php_openssl_get_x509_list_id(void);
@ -265,13 +265,13 @@ static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) /* {{{ */
static int php_x509_fingerprint_cmp(X509 *peer, const char *method, const char *expected TSRMLS_DC)
{
char *fingerprint;
int fingerprint_len;
zend_string *fingerprint;
int result = -1;
if (php_openssl_x509_fingerprint(peer, method, 0, &fingerprint, &fingerprint_len TSRMLS_CC) == SUCCESS) {
result = strcmp(expected, fingerprint);
efree(fingerprint);
fingerprint = php_openssl_x509_fingerprint(peer, method, 0 TSRMLS_CC);
if (fingerprint) {
result = strcmp(expected, fingerprint->val);
STR_RELEASE(fingerprint);
}
return result;

View File

@ -1958,7 +1958,6 @@ SPL_METHOD(RecursiveCallbackFilterIterator, getChildren)
return;
}
//??? intern = Z_SPLDUAL_IT_P(getThis());
SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval);
@ -2686,13 +2685,8 @@ static inline void spl_caching_it_next(spl_dual_it_object *intern TSRMLS_DC)
}
use_copy = zend_make_printable_zval(&intern->u.caching.zstr, &expr_copy TSRMLS_CC);
if (use_copy) {
ZVAL_COPY(&intern->u.caching.zstr, &expr_copy);
//??? INIT_PZVAL(intern->u.caching.zstr);
//zval_copy_ctor(&intern->u.caching.zstr);
zval_dtor(&expr_copy);
ZVAL_COPY_VALUE(&intern->u.caching.zstr, &expr_copy);
} else if (Z_REFCOUNTED(intern->u.caching.zstr)) {
//??? INIT_PZVAL(intern->u.caching.zstr);
//zval_copy_ctor(&intern->u.caching.zstr);
Z_ADDREF(intern->u.caching.zstr);
}
}

View File

@ -180,6 +180,7 @@ static zend_string *php_hex2bin(const unsigned char *old, const size_t oldlen)
}
ret[i] = d;
}
ret[i] = '\0';
return str;
}

View File

@ -290,7 +290,7 @@ static int le_xml_parser;
/* {{{ startup, shutdown and info functions */
static PHP_GINIT_FUNCTION(xml)
{
xml_globals->default_encoding = "UTF-8";
xml_globals->default_encoding = (XML_Char*)"UTF-8";
}
static void *php_xml_malloc_wrapper(size_t sz)
@ -727,11 +727,13 @@ void _xml_startElementHandler(void *userData, const XML_Char *name, const XML_Ch
array_init(&args[2]);
while (attributes && *attributes) {
zval tmp;
att = _xml_decode_tag(parser, (const char *)attributes[0]);
val = xml_utf8_decode(attributes[1], strlen((char *)attributes[1]), parser->target_encoding);
// TODO: avoid reallocation ???
add_assoc_str(&args[2], att->val, val);
ZVAL_STR(&tmp, val);
zend_symtable_update(Z_ARRVAL(args[2]), att, &tmp);
attributes += 2;
@ -762,11 +764,13 @@ void _xml_startElementHandler(void *userData, const XML_Char *name, const XML_Ch
attributes = (const XML_Char **) attrs;
while (attributes && *attributes) {
zval tmp;
att = _xml_decode_tag(parser, (const char *)attributes[0]);
val = xml_utf8_decode(attributes[1], strlen((char *)attributes[1]), parser->target_encoding);
// TODO: avoid reallocation ???
add_assoc_str(&atr, att->val, val);
ZVAL_STR(&tmp, val);
zend_symtable_update(Z_ARRVAL(atr), att, &tmp);
atcnt++;
attributes += 2;
@ -889,7 +893,6 @@ void _xml_characterDataHandler(void *userData, const XML_Char *s, int len)
decoded_value->val, decoded_value->len + 1);
STR_RELEASE(decoded_value);
} else {
// TODO: avoid reallocation ???
add_assoc_str(parser->ctag, "value", decoded_value);
}
@ -919,7 +922,6 @@ void _xml_characterDataHandler(void *userData, const XML_Char *s, int len)
_xml_add_to_info(parser,parser->ltags[parser->level-1] + parser->toffset);
add_assoc_string(&tag, "tag", parser->ltags[parser->level-1] + parser->toffset);
// TODO: avoid reallocation ???
add_assoc_str(&tag, "value", decoded_value);
add_assoc_string(&tag, "type", "cdata");
add_assoc_long(&tag, "level", parser->level);
@ -1109,11 +1111,11 @@ static void php_xml_parser_create_impl(INTERNAL_FUNCTION_PARAMETERS, int ns_supp
encoding = XML(default_encoding);
auto_detect = 1;
} else if (strcasecmp(encoding_param, "ISO-8859-1") == 0) {
encoding = "ISO-8859-1";
encoding = (XML_Char*)"ISO-8859-1";
} else if (strcasecmp(encoding_param, "UTF-8") == 0) {
encoding = "UTF-8";
encoding = (XML_Char*)"UTF-8";
} else if (strcasecmp(encoding_param, "US-ASCII") == 0) {
encoding = "US-ASCII";
encoding = (XML_Char*)"US-ASCII";
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unsupported source encoding \"%s\"", encoding_param);
RETURN_FALSE;
@ -1128,7 +1130,7 @@ static void php_xml_parser_create_impl(INTERNAL_FUNCTION_PARAMETERS, int ns_supp
parser = ecalloc(1, sizeof(xml_parser));
parser->parser = XML_ParserCreate_MM((auto_detect ? NULL : encoding),
&php_xml_mem_hdlrs, ns_param);
&php_xml_mem_hdlrs, (XML_Char*)ns_param);
parser->target_encoding = encoding;
parser->case_folding = 1;
@ -1372,7 +1374,7 @@ PHP_FUNCTION(xml_parse)
ZEND_FETCH_RESOURCE(parser, xml_parser *, pind, -1, "XML Parser", le_xml_parser);
parser->isparsing = 1;
ret = XML_Parse(parser->parser, data, data_len, isFinal);
ret = XML_Parse(parser->parser, (XML_Char*)data, data_len, isFinal);
parser->isparsing = 0;
RETVAL_LONG(ret);
}
@ -1417,7 +1419,7 @@ PHP_FUNCTION(xml_parse_into_struct)
XML_SetCharacterDataHandler(parser->parser, _xml_characterDataHandler);
parser->isparsing = 1;
ret = XML_Parse(parser->parser, data, data_len, 1);
ret = XML_Parse(parser->parser, (XML_Char*)data, data_len, 1);
parser->isparsing = 0;
RETVAL_LONG(ret);
@ -1566,7 +1568,7 @@ PHP_FUNCTION(xml_parser_set_option)
case PHP_XML_OPTION_TARGET_ENCODING: {
xml_encoding *enc;
convert_to_string_ex(val);
enc = xml_get_encoding(Z_STRVAL_P(val));
enc = xml_get_encoding((XML_Char*)Z_STRVAL_P(val));
if (enc == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported target encoding \"%s\"", Z_STRVAL_P(val));
RETURN_FALSE;
@ -1625,7 +1627,7 @@ PHP_FUNCTION(utf8_encode)
return;
}
encoded = xml_utf8_encode(arg, arg_len, "ISO-8859-1");
encoded = xml_utf8_encode(arg, arg_len, (XML_Char*)"ISO-8859-1");
if (encoded == NULL) {
RETURN_FALSE;
}
@ -1645,7 +1647,7 @@ PHP_FUNCTION(utf8_decode)
return;
}
decoded = xml_utf8_decode(arg, arg_len, "ISO-8859-1");
decoded = xml_utf8_decode((XML_Char*)arg, arg_len, (XML_Char*)"ISO-8859-1");
if (decoded == NULL) {
RETURN_FALSE;
}

View File

@ -415,7 +415,7 @@ PHP_FUNCTION(apache_request_headers) /* {{{ */
HashTable *headers;
zend_string *key;
char *value;
HashPosition pos;
zval tmp;
if (zend_parse_parameters_none() == FAILURE) {
return;
@ -426,13 +426,10 @@ PHP_FUNCTION(apache_request_headers) /* {{{ */
array_init_size(return_value, zend_hash_num_elements(headers));
zend_hash_internal_pointer_reset_ex(headers, &pos);
while ((value = zend_hash_get_current_data_ptr_ex(headers, &pos)) != NULL) {
zend_hash_get_current_key_ex(headers, &key, NULL, 0, &pos);
//???
add_assoc_string_ex(return_value, key->val, key->len, value);
zend_hash_move_forward_ex(headers, &pos);
}
ZEND_HASH_FOREACH_STR_KEY_PTR(headers, key, value) {
ZVAL_STRING(&tmp, value);
zend_symtable_update(Z_ARRVAL_P(return_value), key, &tmp);
} ZEND_HASH_FOREACH_END();
}
/* }}} */