Re: [PATCH] rev. 2 of my apache2filters SEGV fixes
| From: | Brian Havard | Date: | Thu, 11 Apr 2002 10:58:43 +0000 |
| Subject: | Re: [PATCH] rev. 2 of my apache2filters SEGV fixes | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-82568@lists.php.net to get a copy of this message | ||
On Thu, 11 Apr 2002 01:14:37 -0400 (EDT), Cliff Woolley wrote:
>On Thu, 11 Apr 2002, Brian Havard wrote:
>
>> > - while (str_length > 0) {
>...
>> > - str += now;
>> > - str_length -= now;
>> > - }
>...
>> >
>> > - return str_length;
>> > + return 0; /* we wrote everything, we promise! */
>>
>> Why did you change this to return 0? It breaks ImageJpeg
>> (and likely other things) as GD checks that the return value
>> matches the passed length & aborts if it doesn't.
>
>
>Because the old version was already always returning 0. If that's
>incorrect, it was incorrect before was well.
Well, actually, that's quite possible (I only just upgraded my GD library
to support JPEG). Inside the GD library (gd_jpeg.c:702 in GD 1.8.4) it
compares the return value of gdPutBuf() to the requested write size &
aborts if it doesn't match. This value is ultimately the return value of
php_apache_sapi_ub_write() which tells me that it should be returning the
number of bytes written. The call stack actually looks like this:
[...]
empty_output_buffer
gdPutBuf
_php_image_output_putbuf
php_write
php_body_write
php_ub_body_write
php_ub_body_write_no_header
php_apache_sapi_ub_write
When I change php_apache_sapi_ub_write() to return str_length instead of 0
(after the new patch so str_length is the full write size) the JPEG is
written in full rather than just the first 4k.
--
______________________________________________________________________________
| Brian Havard | "He is not the messiah! |
| brianh@kheldar.apana.org.au | He's a very naughty boy!" - Life of Brian |
------------------------------------------------------------------------------