Bug #66625 [NEW]: imagescale() segmentation fault on 64bits environment

From: Date: Sun, 02 Feb 2014 03:50:24 +0000
Subject: Bug #66625 [NEW]: imagescale() segmentation fault on 64bits environment
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184118@lists.php.net to get a copy of this message
From:             yoya at awm dot jp
Operating system: Any
PHP version:      5.5.8
Package:          GD related
Bug Type:         Bug
Bug description:imagescale() segmentation fault on 64bits environment

Description:
------------
* ext/gd.c
----
PHP_FUNCTION(imagescale)
{
        zval *IM;
        gdImagePtr im;
        gdImagePtr im_scaled;
        int new_width, new_height = -1;
        gdInterpolationMethod method = GD_BILINEAR_FIXED;

        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|ll",
&IM, &new_width, &new_height, &method) == FAILURE)  {
----

On 64 bits environment ,'l'(long) have 64 bits width, int and
gdInterpolationMethod type have 32 bits, so IM pointer be destroyed by
value of other variables.

This problem related to id:65171, I guess.
- https://bugs.php.net/bug.php?id=65171


Test script:
---------------
<?php

$data = file_get_contents($argv[1]);
$im = ImageCreateFromString($data);
$im2 = imagescale($im, 256, 192, IMG_NEAREST_NEIGHBOUR);
imagepng($im2, 'output.png');

Actual result:
--------------
Segmentation fault

-- 
Edit bug report at https://bugs.php.net/bug.php?id=66625&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=66625&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=66625&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=66625&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=66625&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=66625&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=66625&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=66625&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=66625&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=66625&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=66625&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=66625&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=66625&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=66625&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66625&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=66625&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=66625&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=66625&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66625&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=66625&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=66625&r=mysqlcfg



Thread (4 messages)

« previous php.bugs (#184118) next »