if (dest.data) {
free(dest.data);
}
+ if (src.data) {
+ free(src.data);
+ }
if (src.data && src.data != dest.data) {
free(src.data);
}
BODY *bod=NULL, *topbod=NULL;
PART *mypart=NULL, *part;
PARAMETER *param, *disp_param = NULL, *custom_headers_param = NULL, *tmp_param = NULL;
- char tmp[SENDBUFLEN + 1], *mystring=NULL, *t=NULL, *tempstring=NULL;
+ char *tmp=NULL, *mystring=NULL, *t=NULL, *tempstring=NULL;
int toppart = 0;
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &envelope, &body) == FAILURE) {
disp_param->next = tmp_param;
tmp_param = disp_param;
}
- bod->parameter = disp_param;
+ bod->parameter = disp_param;
}
}
if (zend_hash_find(Z_ARRVAL_PP(data), "subtype", sizeof("subtype"), (void **) &pvalue)== SUCCESS) {
}
rfc822_encode_body_7bit(env, topbod);
+
+ tmp = emalloc(SENDBUFLEN + 1);
+
rfc822_header(tmp, env, topbod);
/* add custom envelope headers */
/* yucky default */
if (!cookie) {
cookie = "-";
- } else if (strlen(cookie) > (sizeof(tmp) - 2 - 2)) { /* validate cookie length -- + CRLF */
+ } else if (strlen(cookie) > (SENDBUFLEN - 2 - 2 - 2)) { /* validate cookie length -- + CRLF * 2 */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The boudary should be no longer then 4kb");
RETVAL_FALSE;
goto done;
/* for each part */
do {
- t=tmp;
- /* build cookie */
- sprintf(t, "--%s%s", cookie, CRLF);
-
+ t = tmp;
+
/* append mini-header */
+ *t = '\0';
rfc822_write_body_header(&t, &part->body);
- /* write terminating blank line */
- strcat(t, CRLF);
-
/* output cookie, mini-header, and contents */
- spprintf(&tempstring, 0, "%s%s", mystring, tmp);
+ spprintf(&tempstring, 0, "%s--%s%s%s%s", mystring, cookie, CRLF, tmp, CRLF);
efree(mystring);
mystring=tempstring;
} while ((part = part->next)); /* until done */
/* output trailing cookie */
- spprintf(&tempstring, 0, "%s--%s--%s", mystring, tmp, CRLF);
+ spprintf(&tempstring, 0, "%s--%s--%s", mystring, cookie, CRLF);
efree(mystring);
mystring=tempstring;
} else if (bod) {
- spprintf(&tempstring, 0, "%s%s%s", mystring, bod->contents.text.data, CRLF);
- efree(mystring);
- mystring=tempstring;
+ spprintf(&tempstring, 0, "%s%s%s", mystring, bod->contents.text.data, CRLF);
+ efree(mystring);
+ mystring=tempstring;
} else {
efree(mystring);
RETVAL_FALSE;
RETVAL_STRING(tempstring, 0);
done:
+ if (tmp) {
+ efree(tmp);
+ }
mail_free_body(&topbod);
mail_free_envelope(&env);
}
addresstmp = addresslist;
if ((len = _php_imap_address_size(addresstmp))) {
- tmpstr = (char *) malloc(len + 1);
+ tmpstr = (char *) pemalloc(len + 1, 1);
tmpstr[0] = '\0';
rfc822_write_address(tmpstr, addresstmp);
*fulladdress = tmpstr;
}
return NULL;
} else {
- char *buf = malloc(size + 1);
+ char *buf = pemalloc(size + 1, 1);
if (f(stream, size, buf)) {
buf[size] = '\0';
void exec_php(BLOBCALLBACK b, PARAMDSC *res, ISC_SHORT *init)
{
int result, remaining = b->blob_total_length, i = 0;
- char *code = malloc(remaining+1);
+ char *code = pemalloc(remaining+1, 1);
ISC_USHORT read;
for (code[remaining] = '\0'; remaining > 0; remaining -= read)
php_stream_statbuf stat_ssb;
switch (Z_TYPE_P(what)) {
- case IS_STRING:
- if(!php_stream_stat_path(Z_STRVAL_P(what), &stat_ssb)) {
- return MIME_MAGIC_OK;
- }
- break;
- case IS_RESOURCE:
- {
- php_stream *stream;
-
- php_stream_from_zval_no_verify(stream, &what);
- if(!php_stream_stat(stream, &stat_ssb)) {
- return MIME_MAGIC_OK;
+ case IS_STRING:
+ if (php_stream_stat_path_ex(Z_STRVAL_P(what), PHP_STREAM_URL_STAT_QUIET, &stat_ssb, NULL)) {
+ if (MIME_MAGIC_G(debug)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Non-statable file path (%s)", Z_STRVAL_P(what));
+ }
+ return MIME_MAGIC_ERROR;
}
- }
- break;
+ break;
+ case IS_RESOURCE:
+ {
+ php_stream *stream;
+
+ php_stream_from_zval_no_verify(stream, &what);
+ if (php_stream_stat(stream, &stat_ssb)) {
+ if (MIME_MAGIC_G(debug)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Non-statable file path (%s)", Z_STRVAL_P(what));
+ }
+ return MIME_MAGIC_ERROR;
+ }
+ }
+ break;
+ default:
+ return MIME_MAGIC_OK;
}
switch (stat_ssb.sb.st_mode & S_IFMT) {
}
/* }}} */
-/* {{{ proto bool openssl_pkcs12_read(mixed PKCS12, array &certs, string pass)
+/* {{{ proto bool openssl_pkcs12_read(string PKCS12, array &certs, string pass)
Parses a PKCS12 to an array */
PHP_FUNCTION(openssl_pkcs12_read)
{
- zval *zp12 = NULL, *zout = NULL, *zextracerts, *zcert, *zpkey;
- char * pass;
- int pass_len;
+ zval *zout = NULL, *zextracerts, *zcert, *zpkey;
+ char *pass, *zp12;
+ int pass_len, zp12_len;
PKCS12 * p12 = NULL;
EVP_PKEY * pkey = NULL;
X509 * cert = NULL;
BIO * bio_in = NULL;
int i;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzs", &zp12, &zout, &pass, &pass_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szs", &zp12, &zout, &pass, &pass_len) == FAILURE) {
return;
}
bio_in = BIO_new(BIO_s_mem());
- if(!BIO_write(bio_in, Z_STRVAL_P(zp12), Z_STRLEN_P(zp12)))
+ if(!BIO_write(bio_in, zp12, zp12_len))
goto cleanup;
if(d2i_PKCS12_bio(bio_in, &p12)) {
RECORD_ERROR(stmt);
return 0;
}
- strncpy(S->name, Z_STRVAL_P(val), sizeof(S->name));
- S->name[sizeof(S->name)] = 0;
+ strlcpy(S->name, Z_STRVAL_P(val), sizeof(S->name));
break;
}
return 1;
S->param_lengths[param->paramno] = 1;
S->param_formats[param->paramno] = 1;
} else {
+ SEPARATE_ZVAL_IF_NOT_REF(¶m->parameter);
convert_to_string(param->parameter);
S->param_values[param->paramno] = Z_STRVAL_P(param->parameter);
S->param_lengths[param->paramno] = Z_STRLEN_P(param->parameter);
PHP_MINIT_FUNCTION(sockets);
PHP_MINFO_FUNCTION(sockets);
-PHP_RINIT_FUNCTION(sockets);
PHP_RSHUTDOWN_FUNCTION(sockets);
PHP_FUNCTION(socket_select);
PHP_MINIT_FUNCTION(sqlite);
PHP_MSHUTDOWN_FUNCTION(sqlite);
-PHP_RINIT_FUNCTION(sqlite);
PHP_RSHUTDOWN_FUNCTION(sqlite);
PHP_MINFO_FUNCTION(sqlite);
extern int sqlite_decode_binary(const unsigned char *in, unsigned char *out);
#define php_sqlite_encode_binary(in, n, out) sqlite_encode_binary((const unsigned char *)in, n, (unsigned char *)out)
-#define php_sqlite_decode_binary(in, out) sqlite_decode_binary((const unsigned char *)in, (unsigned char *)out)
+#define php_sqlite_decode_binary(in, out) in && *in ? sqlite_decode_binary((const unsigned char *)in, (unsigned char *)out) : 0
static int sqlite_count_elements(zval *object, long *count TSRMLS_DC);
sqlite_functions,
PHP_MINIT(sqlite),
PHP_MSHUTDOWN(sqlite),
- PHP_RINIT(sqlite),
+ NULL,
PHP_RSHUTDOWN(sqlite),
PHP_MINFO(sqlite),
#if ZEND_MODULE_API_NO >= 20010901