com php-src: Merge branch 'PHP-5.6' into PHP-7.0: ext/gd/gd_c tx.c
| From: | Stanislav Malyshev | Date: | Sun, 27 Nov 2016 22:53:27 +0000 |
| Subject: | com php-src: Merge branch 'PHP-5.6' into PHP-7.0: ext/gd/gd_c tx.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96079@lists.php.net to get a copy of this message | ||
Commit: 1cb58ead7032a4fe11cda07181997705c37610f1
Author: Stanislav Malyshev <stas@php.net> Sun, 27 Nov 2016 14:53:27 -0800
Parents: 54c04befc2817c4ce85fffee47ccd448e280423a 5049ef2f1c496c4964cd147e185c1f765ab0347b
Branches: PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1cb58ead7032a4fe11cda07181997705c37610f1
Log:
Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
Fix #73549: Use after free when stream is passed to imagepng
Bugs:
https://bugs.php.net/73549
Changed paths:
MM ext/gd/gd_ctx.c
Diff:
diff --cc ext/gd/gd_ctx.c
index da82567,acb96e1..206e455
--- a/ext/gd/gd_ctx.c
+++ b/ext/gd/gd_ctx.c
@@@ -42,22 -44,35 +42,32 @@@ static void _php_image_output_ctxfree(s
if(ctx) {
efree(ctx);
}
-}
+} /* }}} */
-static void _php_image_stream_putc(struct gdIOCtx *ctx, int c) {
+static void _php_image_stream_putc(struct gdIOCtx *ctx, int c) /* {{{ */ {
char ch = (char) c;
php_stream * stream = (php_stream *)ctx->data;
- TSRMLS_FETCH();
php_stream_write(stream, &ch, 1);
-}
+} /* }}} */
-static int _php_image_stream_putbuf(struct gdIOCtx *ctx, const void* buf, int l)
+static int _php_image_stream_putbuf(struct gdIOCtx *ctx, const void* buf, int l) /* {{{ */
{
php_stream * stream = (php_stream *)ctx->data;
- TSRMLS_FETCH();
return php_stream_write(stream, (void *)buf, l);
-}
+} /* }}} */
-static void _php_image_stream_ctxfree(struct gdIOCtx *ctx)
+static void _php_image_stream_ctxfree(struct gdIOCtx *ctx) /* {{{ */
{
+ if(ctx->data) {
+ ctx->data = NULL;
+ }
+ if(ctx) {
+ efree(ctx);
+ }
+ } /* }}} */
+
+ static void _php_image_stream_ctxfreeandclose(struct gdIOCtx *ctx) /* {{{ */
+ {
- TSRMLS_FETCH();
if(ctx->data) {
php_stream_close((php_stream *) ctx->data);
@@@ -120,9 -134,10 +131,10 @@@ static void _php_image_output_ctx(INTER
if (stream == NULL) {
RETURN_FALSE;
}
+ close_stream = 0;
} else if (Z_TYPE_P(to_zval) == IS_STRING) {
if (CHECK_ZVAL_NULL_PATH(to_zval)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid 2nd parameter, filename must not
contain null bytes");
+ php_error_docref(NULL, E_WARNING, "Invalid 2nd parameter, filename must not contain null
bytes");
RETURN_FALSE;
}