Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:rkwasny
php
php-5.1.2-CVE-2006-1017.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File php-5.1.2-CVE-2006-1017.patch of Package php
--- ext/imap/php_imap.c 2006/01/05 00:47:16 1.208.2.4 +++ ext/imap/php_imap.c 2006/01/28 08:07:20 1.208.2.7 @@ -26,7 +26,7 @@ | PHP 4.0 updates: Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: php_imap.c,v 1.208.2.4 2006/01/05 00:47:16 iliaa Exp $ */ +/* $Id: php_imap.c,v 1.208.2.7 2006/01/28 08:07:20 mike Exp $ */ #define IMAP41 @@ -36,6 +36,7 @@ #include "php.h" #include "php_ini.h" +#include "php_streams.h" #include "ext/standard/php_string.h" #include "ext/standard/info.h" #include "ext/standard/file.h" @@ -67,6 +68,9 @@ static void _php_imap_parse_address(ADDRESS *addresslist, char **fulladdress, zval *paddress TSRMLS_DC); static int _php_imap_address_size(ADDRESS *addresslist); +/* the gets we use */ +static char *php_mail_gets(readfn_t f, void *stream, unsigned long size, GETS_DATA *md); + /* These function declarations are missing from the IMAP header files... */ void rfc822_date(char *date); char *cpystr(const char *str); @@ -93,6 +97,7 @@ PHP_FE(imap_body, NULL) PHP_FE(imap_bodystruct, NULL) PHP_FE(imap_fetchbody, NULL) + PHP_FE(imap_savebody, NULL) PHP_FE(imap_fetchheader, NULL) PHP_FE(imap_fetchstructure, NULL) PHP_FE(imap_expunge, NULL) @@ -418,6 +423,7 @@ imap_globals->quota_return = NIL; imap_globals->imap_acl_list = NIL; #endif + imap_globals->gets_stream = NIL; } /* }}} */ @@ -460,6 +466,9 @@ /* lets allow NIL */ REGISTER_LONG_CONSTANT("NIL", NIL, CONST_PERSISTENT | CONST_CS); + /* plug in our gets */ + mail_parameters(NIL, SET_GETS, (void *) php_mail_gets); + /* set default timeout values */ mail_parameters(NIL, SET_OPENTIMEOUT, (void *) FG(default_socket_timeout)); mail_parameters(NIL, SET_READTIMEOUT, (void *) FG(default_socket_timeout)); @@ -650,6 +659,7 @@ { IMAPG(imap_errorstack) = NIL; IMAPG(imap_alertstack) = NIL; + IMAPG(gets_stream) = NIL; return SUCCESS; } /* }}} */ @@ -1845,6 +1855,57 @@ /* }}} */ +/* {{{ proto bool imap_savebody(resource stream_id, string|resource file, int msg_no[, string section = ""[, int options = 0]]) + Save a specific body section to a file */ +PHP_FUNCTION(imap_savebody) +{ + zval *stream, *out; + pils *imap_ptr = NULL; + php_stream *writer = NULL; + char *section = ""; + int section_len = 0, close_stream = 1; + long msgno, flags = 0; + + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rzl|sl", &stream, &out, &msgno, §ion, §ion_len, &flags)) { + RETURN_FALSE; + } + + ZEND_FETCH_RESOURCE(imap_ptr, pils *, &stream, -1, "imap", le_imap); + + if (!imap_ptr) { + RETURN_FALSE; + } + + switch (Z_TYPE_P(out)) + { + case IS_LONG: + case IS_RESOURCE: + close_stream = 0; + php_stream_from_zval(writer, &out); + break; + + default: + convert_to_string_ex(&out); + writer = php_stream_open_wrapper(Z_STRVAL_P(out), "wb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL); + break; + } + + if (!writer) { + RETURN_FALSE; + } + + IMAPG(gets_stream) = writer; + mail_fetchbody_full(imap_ptr->imap_stream, msgno, section, NULL, flags); + IMAPG(gets_stream) = NULL; + + if (close_stream) { + php_stream_close(writer); + } + + RETURN_TRUE; +} +/* }}} */ + /* {{{ proto string imap_base64(string text) Decode BASE64 encoded text */ PHP_FUNCTION(imap_base64) @@ -4143,6 +4204,52 @@ RETURN_TRUE; } else { RETURN_FALSE; + } +} +/* }}} */ + +#define GETS_FETCH_SIZE 8196LU +/* {{{ php_mail_gets */ +static char *php_mail_gets(readfn_t f, void *stream, unsigned long size, GETS_DATA *md) +{ + TSRMLS_FETCH(); + + /* write to the gets stream if it is set, + otherwise forward to c-clients gets */ + if (IMAPG(gets_stream)) { + char buf[GETS_FETCH_SIZE]; + + while (size) { + unsigned long read; + + if (size > GETS_FETCH_SIZE) { + read = GETS_FETCH_SIZE; + size -=GETS_FETCH_SIZE; + } else { + read = size; + size = 0; + } + + if (!f(stream, read, buf)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to read from socket"); + break; + } else if (read != php_stream_write(IMAPG(gets_stream), buf, read)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write to stream"); + break; + } + } + return NULL; + } else { + char *buf = malloc(size + 1); + + if (f(stream, size, buf)) { + buf[size] = '\0'; + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to read from socket"); + free(buf); + buf = NULL; + } + return buf; } } /* }}} */ --- ext/imap/php_imap.h 2006/01/01 12:50:08 1.32.2.1 +++ ext/imap/php_imap.h 2006/01/27 19:46:11 1.32.2.2 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_imap.h,v 1.32.2.1 2006/01/01 12:50:08 sniper Exp $ */ +/* $Id: php_imap.h,v 1.32.2.2 2006/01/27 19:46:11 mike Exp $ */ #ifndef PHP_IMAP_H #define PHP_IMAP_H @@ -114,6 +114,7 @@ PHP_FUNCTION(imap_body); PHP_FUNCTION(imap_fetchstructure); PHP_FUNCTION(imap_fetchbody); +PHP_FUNCTION(imap_savebody); PHP_FUNCTION(imap_expunge); PHP_FUNCTION(imap_delete); PHP_FUNCTION(imap_undelete); @@ -205,6 +206,8 @@ zval **quota_return; zval *imap_acl_list; #endif + /* php_stream for php_mail_gets() */ + php_stream *gets_stream; ZEND_END_MODULE_GLOBALS(imap) #ifdef ZTS
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor