summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2007-02-12 20:30:52 +0000
committerAntony Dovgal <tony2001@php.net>2007-02-12 20:30:52 +0000
commit511463854b2ea520604ec22c0d0d80cc329727ae (patch)
tree48801eebdfb688f0dbc7d3425aac71c1eb3483f0
parent634615cd42adfea1dabc3d14bf881a7d0e6fa302 (diff)
downloadphp-git-511463854b2ea520604ec22c0d0d80cc329727ae.tar.gz
MFH: fix #40109 (iptcembed fails on non-jfif jpegs)
-rw-r--r--NEWS1
-rw-r--r--ext/standard/iptc.c11
2 files changed, 11 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 30df68de7f..9530c3f9ab 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ PHP NEWS
methods). (Tony)
- Fixed bug #40428 (imagepstext() doesn't accept optional parameter). (Pierre)
- Fixed bug #40410 (ext/posix does not compile on MacOS 10.3.9). (Tony)
+- Fixed bug #40109 (iptcembed fails on non-jfif jpegs). (Tony)
- Fixed bug #39836 (SplObjectStorage empty after unserialize). (Marcus)
08 Feb 2007, PHP 5.2.1
diff --git a/ext/standard/iptc.c b/ext/standard/iptc.c
index 3b80a17b19..81844e7067 100644
--- a/ext/standard/iptc.c
+++ b/ext/standard/iptc.c
@@ -183,6 +183,7 @@ PHP_FUNCTION(iptcembed)
unsigned int spool = 0, done = 0, inx, len;
unsigned char *spoolbuf=0, *poi=0;
struct stat sb;
+ zend_bool written = 0;
switch(ZEND_NUM_ARGS()){
case 3:
@@ -226,7 +227,8 @@ PHP_FUNCTION(iptcembed)
if (spool < 2) {
fstat(fileno(fp), &sb);
- poi = spoolbuf = emalloc(len + sizeof(psheader) + sb.st_size + 1024);
+ poi = spoolbuf = safe_emalloc(1, len + sizeof(psheader) + sb.st_size + 1024, 1);
+ memset(poi, 0, len + sizeof(psheader) + sb.st_size + 1024 + 1);
}
if (php_iptc_get1(fp, spool, poi?&poi:0 TSRMLS_CC) != 0xFF) {
@@ -264,6 +266,13 @@ PHP_FUNCTION(iptcembed)
case M_APP0:
/* APP0 is in each and every JPEG, so when we hit APP0 we insert our new APP13! */
+ case M_APP1:
+ 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 (len & 1) len++; /* make the length even */