~clint-fewbar/ubuntu/precise/php5/php5-5.4-merge

« back to all changes in this revision

Viewing changes to debian/patches/gdIOCtx.patch

  • Committer: Clint Byrum
  • Date: 2012-03-05 18:49:10 UTC
  • mfrom: (0.3.43 sid)
  • Revision ID: clint@ubuntu.com-20120305184910-141dapr4lsn4x2cf
* Merge from Debian unstable. Remaining changes:
  - d/control: build-depend on mysql 5.5 instead of 5.1 for running tests.
  - d/setup-mysql.sh: modify to work with mysql 5.5 differences
  - debian/rules: export DEB_HOST_MULTIARCH properly.
  - Only build php5-sqlite for sqlite3, dropping the obsolete sqlite2.
  - Add build-dependency on lemon, which we now need.
  - Dropped firebird2.1-dev, libc-client-dev, libmcrypt-dev as it is in universe.
  - Dropped libcurl-dev not in the archive.
  - debian/control: replace build-depends on mysql-server with
    mysql-server-core-5.5 and mysql-client-5.5 to avoid upstart and
    mysql-server-5.5 postinst confusion with starting up multiple
    mysqlds listening on the same port.
  - Dropped php5-imap, php5-interbase, php5-mcrypt since we have versions
    already in universe.
  - Suggest php5-suhosin rather than recommends.
  - Dropped libonig-dev and libqgdbm since its in universe. (libonig MIR
    has been declined due to an inactive upstream. So this is probably
    a permanent change).
  - modulelist: Drop imap, interbase, sybase, and mcrypt.
  - debian/rules:
    * Dropped building of mcrypt, imap, and interbase.
    * Install apport hook for php5.
    * stop mysql instance on clean just in case we failed in tests
  - debian/control: Recommend php5-dev for php-pear.
  - d/rules: enable Suhosin patch with PHP5_SUHOSIN=yes
  - d/NEWS: add note explaining that SUHOSIN *is* enabled in the Ubuntu
    package.
  - d/rules: Simplify apache config settings since we never build 
    interbase or firebird.
 * Dropped changes:
  - Pre-Depend on a new enough version of dpkg for dpkg-maintscript-helper
    rather than checking whether it exists at run-time, leading to
    more predictable behaviour on upgrades. This was superseded by
    Debian changes to the same effect.
* PHP 5.4 has landed in unstable
* Imported Upstream version 5.4.0
* Use $(filter pattern...,text) instead of $(findstring find,in) in
  debian/rules to match against space separated list of words and not
  substrings (Closes: #660647)
* Use $(filter pattern...,text) instead of $(findstring find,in) in
  debian/rules to match against space separated list of words and not
  just substrings (i386 != hurd-i386) (Closes: #660647)
* Imported Upstream version 5.4.0~rc8
* Improve maxlifetime script to scan for more SAPIs and scan all *.ini
  in conf.d directory
* Move php5-mysqlnd to Priority: extra to make debcheck happy
* Check for dpkg-maintscript-helper existence in php5-fpm maintainer
  scripts
* Add Pre-Depends: dpkg (>= 1.15.7.2~) | dpkg-maintscript-helper to
  allow single upgrade path (dpkg-maintscript-helper package will be
  provided for Ubuntu Lucid PPA)
* Use corrected module PHPAPI (20100525) and not (220100525)
* Use $ZEND_MODULE_API_NO for $DEBIAN_PHP_API. Check for PHPAPI
  changes, so we don't become binary incompatible without knowing it.
* Update debian/README.Debian.security:
  + register_globals was removed from PHP 5.4
  + Remove safe_mode (removed upstream) and update and reformat text
    slightly
  + Reviewed by english l10n team (thanks a lot)
* php5-fpm now listen on socket instead of localhost by default
  (Closes: #650204)
* Add NEWS about change of default location of php5-fpm socket
* Stop php5-fpm on runlevels 0 1 6 (Closes: #650203)
* Add -ignore_readdir_race to find call in session cleanup (#634864)
* Don't prefix extension list automatically, it's done by subsvars now
  (Closes: #633491)
* Depends on non-forking fuser in psmisc (Closes: #633100)
* php5-common.README.Debian additions and cleanup:
  + Add a paragraph about PHP_INI_SCAN_DIR (Closes: #659123)
  + Reformat README.Debian to common formatting
  + Mention php5-fpm where appropriate
  + Use 'PHP 5' and 'Apache HTTP Server' instead of php5 and apache2
* Textual improvements to README.Debian.security, NEWS
  (closes: #632675,#643015,#658208).
* Imported Upstream version 5.4.0~rc7
  + CVE-2012-0830: Fix PHP remote vulnerability (code injection) in the
    implementation of the max_input_vars configuration variable
  + CVE-2011-3389: Fix possible attack in SSL sockets with SSL 3.0/TLS 1.0.
* ucfize php5-module.* and store priority in module .ini file
* Store dsonames in maintainer scripts to make postrm work
* Make php5enmod idempotent
* Merge all changes from Debian unstable branch (up to 5.3.9-6)
* Fix -Wformat-security error in mysqlnd
* Add php5{en,dis}mod to enable/disable modules from maintainer
  scripts (Closes: #447826, #582320, #627145)
  (Initial work courtesy of Clint Byrum)
* Modify comments in php.inis to match compiled default session
* Adjust new 5.3 patches for 5.4 branch
* Ensure pdo.so is loaded before all other modules
* Add trigger to restart php5-fpm when module is installed/removed
* Remove --with-ttf and --with-t1lib (Closes: #658248, #638755)
* Add debian/NEWS item about missing t1lib functions
* Imported Upstream version 5.4.0~rc6
* Imported Upstream version 5.4.0~rc5
* Update patches for new release
* Disable suhosin patch
* Remove obsolete sqlite(2) module from php5-sqlite
* Use correct signals in php5-fpm init script (Closes: #645934)
* Update gbp.conf for experimental branch
* Imported Upstream version 5.4.0~beta2
* Refresh patches for the 5.4.0beta2 release
* Remove php.ini-paranoid, it's almost useless now
* Remove safe_mode setting from suhosin, it has been removed upstream
* Remove the php_stream stuff to allow compiling with system-wide
  libgd
* php5-common.docs: Don't install non-existant TODO file

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--- a/ext/gd/gd_ctx.c
 
2
+++ b/ext/gd/gd_ctx.c
 
3
@@ -46,33 +46,6 @@ static void _php_image_output_ctxfree(st
 
4
        }
 
5
 }
 
6
 
 
7
-static void _php_image_stream_putc(struct gdIOCtx *ctx, int c)  {
 
8
-       char ch = (char) c;
 
9
-       php_stream * stream = (php_stream *)ctx->data;
 
10
-       TSRMLS_FETCH();
 
11
-       php_stream_write(stream, &ch, 1);
 
12
-}
 
13
-
 
14
-static int _php_image_stream_putbuf(struct gdIOCtx *ctx, const void* buf, int l)
 
15
-{
 
16
-       php_stream * stream = (php_stream *)ctx->data;
 
17
-       TSRMLS_FETCH();
 
18
-       return php_stream_write(stream, (void *)buf, l);
 
19
-}
 
20
-
 
21
-static void _php_image_stream_ctxfree(struct gdIOCtx *ctx)
 
22
-{
 
23
-       TSRMLS_FETCH();
 
24
-
 
25
-       if(ctx->data) {
 
26
-               php_stream_close((php_stream *) ctx->data);
 
27
-               ctx->data = NULL;
 
28
-       }
 
29
-       if(ctx) {
 
30
-               efree(ctx);
 
31
-       }
 
32
-}
 
33
-
 
34
 /* {{{ _php_image_output_ctx */
 
35
 static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, void (*func_p)())
 
36
 {
 
37
@@ -81,12 +54,11 @@ static void _php_image_output_ctx(INTERN
 
38
        int file_len = 0;
 
39
        long quality, basefilter;
 
40
        gdImagePtr im;
 
41
+       FILE *fp = NULL;
 
42
        int argc = ZEND_NUM_ARGS();
 
43
        int q = -1, i;
 
44
        int f = -1;
 
45
        gdIOCtx *ctx = NULL;
 
46
-       zval *to_zval = NULL;
 
47
-       php_stream *stream;
 
48
 
 
49
        /* The third (quality) parameter for Wbmp stands for the threshold when called from image2wbmp().
 
50
         * The third (quality) parameter for Wbmp and Xbm stands for the foreground color index when called
 
51
@@ -103,7 +75,7 @@ static void _php_image_output_ctx(INTERN
 
52
                 * PHP_GDIMG_TYPE_WBM 
 
53
                 * PHP_GDIMG_TYPE_WEBP 
 
54
                 * */
 
55
-               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|z/!ll", &imgind, &to_zval, &quality, &basefilter) == FAILURE) {
 
56
+               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|p!ll", &imgind, &file, &file_len, &quality, &basefilter) == FAILURE) {
 
57
                        return;
 
58
                }
 
59
        }
 
60
@@ -117,21 +89,19 @@ static void _php_image_output_ctx(INTERN
 
61
                }
 
62
        }
 
63
 
 
64
-       if (argc > 1 && to_zval != NULL) {
 
65
-               if (Z_TYPE_P(to_zval) == IS_RESOURCE) {
 
66
-                       php_stream_from_zval_no_verify(stream, &to_zval);
 
67
-                       if (stream == NULL) {
 
68
-                               RETURN_FALSE;
 
69
-                       }
 
70
-               } else if (Z_TYPE_P(to_zval) == IS_STRING) {
 
71
-                       stream = php_stream_open_wrapper(Z_STRVAL_P(to_zval), "wb", REPORT_ERRORS|IGNORE_PATH|IGNORE_URL_WIN, NULL);
 
72
-                       if (stream == NULL) {
 
73
-                               RETURN_FALSE;
 
74
-                       }
 
75
-               } else {
 
76
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid 2nd parameter, it must a filename or a stream");
 
77
+       if (argc > 1 && file_len) {
 
78
+               if (strlen(file) != file_len) {
 
79
+                       RETURN_FALSE;
 
80
+               }
 
81
+               PHP_GD_CHECK_OPEN_BASEDIR(file, "Invalid filename");
 
82
+
 
83
+               fp = VCWD_FOPEN(file, "wb");
 
84
+               if (!fp) {
 
85
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' for writing: %s", file, strerror(errno));
 
86
                        RETURN_FALSE;
 
87
                }
 
88
+
 
89
+               ctx = gdNewFileCtx(fp);
 
90
        } else {
 
91
                ctx = emalloc(sizeof(gdIOCtx));
 
92
                ctx->putC = _php_image_output_putc;
 
93
@@ -145,14 +115,6 @@ static void _php_image_output_ctx(INTERN
 
94
 #endif
 
95
        }
 
96
 
 
97
-       if (!ctx)       {
 
98
-               ctx = emalloc(sizeof(gdIOCtx));
 
99
-               ctx->putC = _php_image_stream_putc;
 
100
-               ctx->putBuf = _php_image_stream_putbuf;
 
101
-               ctx->gd_free = _php_image_stream_ctxfree;
 
102
-               ctx->data = (void *)stream;
 
103
-       }
 
104
-
 
105
        switch(image_type) {
 
106
                case PHP_GDIMG_CONVERT_WBM:
 
107
                        if(q<0||q>255) {
 
108
@@ -189,11 +151,12 @@ static void _php_image_output_ctx(INTERN
 
109
                        break;
 
110
        }
 
111
 
 
112
-#if HAVE_LIBGD204
 
113
        ctx->gd_free(ctx);
 
114
-#else
 
115
-       ctx->free(ctx);
 
116
-#endif
 
117
+
 
118
+       if(fp) {
 
119
+               fflush(fp);
 
120
+               fclose(fp);
 
121
+       }
 
122
 
 
123
        RETURN_TRUE;
 
124
 }