php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10438 problem with pdf_get_pdi_paramter()
Submitted: 2001-04-22 04:15 UTC Modified: 2001-10-08 18:48 UTC
From: graeme at inetix dot com dot au Assigned:
Status: Closed Package: PDF related
PHP Version: 4.0 Latest CVS (15/04/2001) OS: Linux x86
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: graeme at inetix dot com dot au
New email:
PHP Version: OS:

 

 [2001-04-22 04:15 UTC] graeme at inetix dot com dot au
Configure line is:
'./configure' '--with-apxs=/usr/local/apache/bin/apxs' '--enable-track-vars' '--enable-magic-quotes' '--enable-debug' '--with-mysql=shared,/usr' '--with-dom=shared' '--with-pgsql=shared' '--with-xml' '--enable-bcmath=shared' '--with-swf=shared,/usr' '--enable-exif' '--enable-ftp=shared' '--with-gd=shared' '--with-sablot=shared' '--enable-sablot-errors-descriptive' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--enable-gd-imgstrttf' '--with-pdflib=shared'


When attempting to call pdf_get_pdi_paramter() with the only key currently implemented, "filename", Apache dies with the following error:
FATAL:  emalloc():  Unable to allocate 1076577297 bytes

Compiling PHP with debugging executed the script correctly with the following errors showing up in the logs:
pdf.c(264) :  Freeing 0x0810F184 (372 bytes), script=/usr/local/apache/htdocs/test/index.php
Last leak repeated 17 times
pdf.c(264) :  Freeing 0x08102A94 (372 bytes), script=/usr/local/apache/htdocs/test/index.php
Last leak repeated 17 times

Line 264 is:
static void *pdf_emalloc(PDF *p, size_t size, const char *caller)
{
        return(emalloc(size));
}


Sample script (apologies for long lines):
<?
// create first file
$filepdf = pdf_new();
pdf_open_file($filepdf, "firstfile.pdf");
pdf_begin_page($filepdf, 500, 700);

pdf_moveto($filepdf, 125, 175);
pdf_lineto($filepdf, 375, 175);
pdf_lineto($filepdf, 375, 525);
pdf_lineto($filepdf, 125, 525);
pdf_closepath_stroke($filepdf);

pdf_end_page($filepdf);
pdf_close($filepdf);
// end of first file

// open second file
$pdf = pdf_new();
pdf_open_file($pdf);

// open open first file and read values
$pdi = pdf_open_pdi($pdf, "firstfile.pdf", "", 0);
$page= pdf_open_pdi_page($pdf, $pdi, 1, "");
$width = pdf_get_pdi_value($pdf, "width", $pdi, $page, 0);
$height = pdf_get_pdi_value($pdf, "height", $pdi, $page, 0);
$name = pdf_get_pdi_parameter($pdf, "filename", $pdi, $page, 0);

pdf_begin_page($pdf, $width, $height);

// place page from first file into second file
pdf_place_pdi_page($pdf, $page, 0.0, 0.0, 1.0, 1.0);

// now add some text
$font = pdf_findfont($pdf, "Courier", "host", 0);
pdf_setfont($pdf, $font, 10);
pdf_show_xy($pdf, "PDI File: $name", 200, 350);

pdf_close_pdi_page($pdf, $page);

pdf_end_page($pdf);
pdf_close($pdf);

$data = pdf_get_buffer($pdf);
header("Content-type: application/pdf");
header("Content-disposition: inline; filename=test.pdf");
header("Content-length: " . strlen($data));
echo $data;
?>

Comment out call to pdf_get_pdi_parameter() to compare


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-08 15:56 UTC] rjs@php.net
This is a bug in the PDFlib core. It will be fixed with the next maintainace release of PDFlib (V4.0.2)
 [2001-10-08 18:48 UTC] sniper@php.net
not a bug in PHP -> closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 13:01:30 2024 UTC