Menu

#48 Fix bug in Image() when writing to disk should use tempnam()

closed
nobody
None
5
2012-10-09
2011-12-09
Matt
No

Piwik, open source web analytics, is a very happy TCPDF user.

We have found a bug. In tcpdf.php the code to write to files is not refactored, and it seems there are a few differences between the uses of fopen etc.

In particular in Image() the filename used to record on disk does not use tempnam (as opposed to the sendToDisk() at line 8234)

Please apply the following patch to Tcpdf!
http://dev.piwik.org/trac/changeset/5540#file0

Thanks & keep up the great work

Discussion

  • Matt

    Matt - 2011-12-09

    one line fix

     
  • Nicola Asuni

    Nicola Asuni - 2011-12-10

    The original code is perfectly valid and the patch is wrong.
    The image filename cannot be random, it is created in this way to easily retrieve already processed images.

     
  • Matt

    Matt - 2011-12-11

    If the path is not writable, the image creation will fail and throw fopen/fwrite/fclose warning on screens. When using tempnam, the directory is first checked to see if it's writable, if not, will write in /tmp/ which is enough for us to generate the image for hard-inclusion in PDF.

    Maybe my patch is not fixing the bug in the best way, but it certainly fixes a bug in tcpdf for us, thanks!

     

Log in to post a comment.