tony2001                Mon Feb 12 20:27:48 2007 UTC

  Modified files:              
    /php-src/ext/standard       iptc.c 
  Log:
  fix bug #40109 (iptcembed fails on non-jfif jpegs)
  + use safe_emalloc
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/iptc.c?r1=1.59&r2=1.60&diff_format=u
Index: php-src/ext/standard/iptc.c
diff -u php-src/ext/standard/iptc.c:1.59 php-src/ext/standard/iptc.c:1.60
--- php-src/ext/standard/iptc.c:1.59    Mon Jan  1 09:29:32 2007
+++ php-src/ext/standard/iptc.c Mon Feb 12 20:27:48 2007
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: iptc.c,v 1.59 2007/01/01 09:29:32 sebastian Exp $ */
+/* $Id: iptc.c,v 1.60 2007/02/12 20:27:48 tony2001 Exp $ */
 
 /*
  * Functions to parse & compse IPTC data.
@@ -186,6 +186,7 @@
        unsigned int spool = 0, done = 0, inx;  
        unsigned char *spoolbuf=0, *poi=0;
        struct stat sb;
+       zend_bool written = 0;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SZ|l", &iptcdata, 
&iptcdata_len, &pp_jpeg_file, &spool) == FAILURE ||
                php_stream_path_param_encode(pp_jpeg_file, &jpeg_file, 
&jpeg_file_len, REPORT_ERRORS, FG(default_context)) == FAILURE) {
@@ -204,7 +205,8 @@
        if (spool < 2) {
                fstat(fileno(fp), &sb);
 
-               poi = spoolbuf = emalloc(iptcdata_len + sizeof(psheader) + 
sb.st_size + 1024);
+               poi = spoolbuf = safe_emalloc(1, iptcdata_len + 
sizeof(psheader) + sb.st_size + 1024, 1);
+               memset(poi, 0, iptcdata_len + sizeof(psheader) + sb.st_size + 
1024 + 1);
        } 
 
        if (php_iptc_get1(fp, spool, poi?&poi:0 TSRMLS_CC) != 0xFF) {
@@ -242,6 +244,14 @@
 
                        case M_APP0:
                                /* APP0 is in each and every JPEG, so when we 
hit APP0 we insert our new APP13! */
+                       case M_APP1:
+                               /* APP1 is present in JFIF */
+                               if (written) {
+                                       /* don't try to write the data twice */
+                                       break;
+                               }
+                               written = 1;
+
                                php_iptc_skip_variable(fp, spool, poi?&poi:0 
TSRMLS_CC);
 
                                if (iptcdata_len & 1) iptcdata_len++; /* make 
the length even */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to