[PHP-CVS] cvs: php-src /ext/standard iptc.c
tony2001Tue Jul 1 08:15:44 2008 UTC Modified files: /php-src/ext/standard iptc.c Log: this should be long http://cvs.php.net/viewvc.cgi/php-src/ext/standard/iptc.c?r1=1.62r2=1.63diff_format=u Index: php-src/ext/standard/iptc.c diff -u php-src/ext/standard/iptc.c:1.62 php-src/ext/standard/iptc.c:1.63 --- php-src/ext/standard/iptc.c:1.62Mon Dec 31 07:12:16 2007 +++ php-src/ext/standard/iptc.c Tue Jul 1 08:15:44 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: iptc.c,v 1.62 2007/12/31 07:12:16 sebastian Exp $ */ +/* $Id: iptc.c,v 1.63 2008/07/01 08:15:44 tony2001 Exp $ */ /* * Functions to parse compse IPTC data. @@ -183,7 +183,8 @@ int jpeg_file_len, iptcdata_len; FILE *fp; unsigned int marker; - unsigned int spool = 0, done = 0, inx; + unsigned int done = 0, inx; + long spool = 0; unsigned char *spoolbuf=0, *poi=0; struct stat sb; zend_bool written = 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard iptc.c /ext/standard/tests/image iptcembed_001.phpt
tony2001Thu May 10 12:21:42 2007 UTC Added files: /php-src/ext/standard/tests/image iptcembed_001.phpt Modified files: /php-src/ext/standard iptc.c Log: fix segfault in iptcembed() http://cvs.php.net/viewvc.cgi/php-src/ext/standard/iptc.c?r1=1.60r2=1.61diff_format=u Index: php-src/ext/standard/iptc.c diff -u php-src/ext/standard/iptc.c:1.60 php-src/ext/standard/iptc.c:1.61 --- php-src/ext/standard/iptc.c:1.60Mon Feb 12 20:27:48 2007 +++ php-src/ext/standard/iptc.c Thu May 10 12:21:42 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: iptc.c,v 1.60 2007/02/12 20:27:48 tony2001 Exp $ */ +/* $Id: iptc.c,v 1.61 2007/05/10 12:21:42 tony2001 Exp $ */ /* * Functions to parse compse IPTC data. @@ -211,16 +211,16 @@ if (php_iptc_get1(fp, spool, poi?poi:0 TSRMLS_CC) != 0xFF) { fclose(fp); - if (poi) { - efree(poi); + if (spoolbuf) { + efree(spoolbuf); } RETURN_FALSE; } if (php_iptc_get1(fp, spool, poi?poi:0 TSRMLS_CC) != 0xD8) { fclose(fp); - if (poi) { - efree(poi); + if (spoolbuf) { + efree(spoolbuf); } RETURN_FALSE; } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/image/iptcembed_001.phpt?view=markuprev=1.1 Index: php-src/ext/standard/tests/image/iptcembed_001.phpt +++ php-src/ext/standard/tests/image/iptcembed_001.phpt --TEST-- iptcembed() and wrong file --FILE-- ?php $file = dirname(__FILE__).'/iptcembed_001.data'; $fp = fopen($file, w); fwrite($fp, b-1-1); fclose($fp); var_dump(iptcembed(-1, $file, -1)); echo Done\n; ? --EXPECTF-- bool(false) Done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard iptc.c
tony2001Mon 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.59r2=1.60diff_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.59Mon 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
[PHP-CVS] cvs: php-src /ext/standard iptc.c
tony2001Fri Dec 8 20:17:31 2006 UTC Modified files: /php-src/ext/standard iptc.c Log: fix typo http://cvs.php.net/viewvc.cgi/php-src/ext/standard/iptc.c?r1=1.57r2=1.58diff_format=u Index: php-src/ext/standard/iptc.c diff -u php-src/ext/standard/iptc.c:1.57 php-src/ext/standard/iptc.c:1.58 --- php-src/ext/standard/iptc.c:1.57Thu Dec 7 21:11:54 2006 +++ php-src/ext/standard/iptc.c Fri Dec 8 20:17:31 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: iptc.c,v 1.57 2006/12/07 21:11:54 andrei Exp $ */ +/* $Id: iptc.c,v 1.58 2006/12/08 20:17:31 tony2001 Exp $ */ /* * Functions to parse compse IPTC data. @@ -187,7 +187,7 @@ unsigned char *spoolbuf=0, *poi=0; struct stat sb; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, SZ|l, iptcdata, iptcdata_len, pp_jpeg_file, spool) == FAILURE || + 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) { return; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard iptc.c
andrei Thu Dec 7 21:11:54 2006 UTC Modified files: /php-src/ext/standard iptc.c Log: Unicode support/safety in iptc* functions. Untested, cause I know crap about IPTC. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/iptc.c?r1=1.56r2=1.57diff_format=u Index: php-src/ext/standard/iptc.c diff -u php-src/ext/standard/iptc.c:1.56 php-src/ext/standard/iptc.c:1.57 --- php-src/ext/standard/iptc.c:1.56Tue Sep 19 10:38:31 2006 +++ php-src/ext/standard/iptc.c Thu Dec 7 21:11:54 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: iptc.c,v 1.56 2006/09/19 10:38:31 dmitry Exp $ */ +/* $Id: iptc.c,v 1.57 2006/12/07 21:11:54 andrei Exp $ */ /* * Functions to parse compse IPTC data. @@ -35,6 +35,7 @@ #include php.h #include php_iptc.h #include ext/standard/head.h +#include ext/standard/file.h #include sys/stat.h @@ -173,56 +174,37 @@ static char psheader[] = \xFF\xED\0\0Photoshop 3.0\08BIM\x04\x04\0\0\0\0; -/* {{{ proto array iptcembed(string iptcdata, string jpeg_file_name [, int spool]) +/* {{{ proto array iptcembed(string iptcdata, string jpeg_file_name [, int spool]) U Embed binary IPTC data into a JPEG image. */ PHP_FUNCTION(iptcembed) { -zval **iptcdata, **jpeg_file, **spool_flag; +zval **pp_jpeg_file; + char *iptcdata, *jpeg_file; + int jpeg_file_len, iptcdata_len; FILE *fp; unsigned int marker; - unsigned int spool = 0, done = 0, inx, len; + unsigned int spool = 0, done = 0, inx; unsigned char *spoolbuf=0, *poi=0; struct stat sb; -switch(ZEND_NUM_ARGS()){ -case 3: -if (zend_get_parameters_ex(3, iptcdata, jpeg_file, spool_flag) == FAILURE) { -WRONG_PARAM_COUNT; -} -convert_to_string_ex(iptcdata); -convert_to_string_ex(jpeg_file); -convert_to_long_ex(spool_flag); - spool = Z_LVAL_PP(spool_flag); -break; - -case 2: -if (zend_get_parameters_ex(2, iptcdata, jpeg_file) == FAILURE) { -WRONG_PARAM_COUNT; -} -convert_to_string_ex(iptcdata); -convert_to_string_ex(jpeg_file); -break; - -default: -WRONG_PARAM_COUNT; -break; -} + 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) { + return; + } -if (php_check_open_basedir(Z_STRVAL_PP(jpeg_file) TSRMLS_CC)) { +if (php_check_open_basedir(jpeg_file TSRMLS_CC)) { RETURN_FALSE; } -if ((fp = VCWD_FOPEN(Z_STRVAL_PP(jpeg_file), rb)) == 0) { -php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to open %s, Z_STRVAL_PP(jpeg_file)); +if ((fp = VCWD_FOPEN(jpeg_file, rb)) == 0) { +php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to open %s, jpeg_file); RETURN_FALSE; } - len = Z_STRLEN_PP(iptcdata); - if (spool 2) { fstat(fileno(fp), sb); - poi = spoolbuf = emalloc(len + sizeof(psheader) + sb.st_size + 1024); + poi = spoolbuf = emalloc(iptcdata_len + sizeof(psheader) + sb.st_size + 1024); } if (php_iptc_get1(fp, spool, poi?poi:0 TSRMLS_CC) != 0xFF) { @@ -262,19 +244,19 @@ /* APP0 is in each and every JPEG, so when we hit APP0 we insert our new APP13! */ php_iptc_skip_variable(fp, spool, poi?poi:0 TSRMLS_CC); - if (len 1) len++; /* make the length even */ + if (iptcdata_len 1) iptcdata_len++; /* make the length even */ - psheader[ 2 ] = (len+28)8; - psheader[ 3 ] = (len+28)0xff; + psheader[ 2 ] = (iptcdata_len+28)8; + psheader[ 3 ] = (iptcdata_len+28)0xff; for (inx = 0; inx 28; inx++) php_iptc_put1(fp, spool, psheader[inx], poi?poi:0 TSRMLS_CC); - php_iptc_put1(fp, spool, (unsigned char)(len8), poi?poi:0 TSRMLS_CC); - php_iptc_put1(fp, spool, (unsigned char)(len0xff), poi?poi:0 TSRMLS_CC); + php_iptc_put1(fp, spool, (unsigned char)(iptcdata_len8), poi?poi:0 TSRMLS_CC); + php_iptc_put1(fp, spool, (unsigned char)(iptcdata_len0xff), poi?poi:0 TSRMLS_CC); - for (inx = 0; inx len; inx++) - php_iptc_put1(fp, spool, Z_STRVAL_PP(iptcdata)[inx], poi?poi:0 TSRMLS_CC); +
[PHP-CVS] cvs: php-src /ext/standard iptc.c
tony2001Wed Aug 30 16:30:03 2006 UTC Modified files: /php-src/ext/standard iptc.c Log: fix leak in iptcembed() http://cvs.php.net/viewvc.cgi/php-src/ext/standard/iptc.c?r1=1.54r2=1.55diff_format=u Index: php-src/ext/standard/iptc.c diff -u php-src/ext/standard/iptc.c:1.54 php-src/ext/standard/iptc.c:1.55 --- php-src/ext/standard/iptc.c:1.54Thu Mar 2 13:12:45 2006 +++ php-src/ext/standard/iptc.c Wed Aug 30 16:30:03 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: iptc.c,v 1.54 2006/03/02 13:12:45 dmitry Exp $ */ +/* $Id: iptc.c,v 1.55 2006/08/30 16:30:03 tony2001 Exp $ */ /* * Functions to parse compse IPTC data. @@ -227,11 +227,17 @@ if (php_iptc_get1(fp, spool, poi?poi:0 TSRMLS_CC) != 0xFF) { fclose(fp); + if (poi) { + efree(poi); + } RETURN_FALSE; } if (php_iptc_get1(fp, spool, poi?poi:0 TSRMLS_CC) != 0xD8) { fclose(fp); + if (poi) { + efree(poi); + } RETURN_FALSE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard iptc.c
iliaa Wed Nov 3 17:17:47 2004 EDT Modified files: /php-src/ext/standard iptc.c Log: emalloc() failures are handled by zend engine. http://cvs.php.net/diff.php/php-src/ext/standard/iptc.c?r1=1.48r2=1.49ty=u Index: php-src/ext/standard/iptc.c diff -u php-src/ext/standard/iptc.c:1.48 php-src/ext/standard/iptc.c:1.49 --- php-src/ext/standard/iptc.c:1.48Tue Jun 22 16:27:46 2004 +++ php-src/ext/standard/iptc.c Wed Nov 3 17:17:45 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: iptc.c,v 1.48 2004/06/22 20:27:46 iliaa Exp $ */ +/* $Id: iptc.c,v 1.49 2004/11/03 22:17:45 iliaa Exp $ */ /* * Functions to parse compse IPTC data. @@ -227,11 +227,6 @@ fstat(fileno(fp), sb); poi = spoolbuf = emalloc(len + sizeof(psheader) + sb.st_size + 1024); - - if (! spoolbuf) { - fclose(fp); - RETURN_FALSE; - } } if (php_iptc_get1(fp, spool, poi?poi:0 TSRMLS_CC) != 0xFF) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard iptc.c
iliaa Tue Jun 22 16:27:46 2004 EDT Modified files: /php-src/ext/standard iptc.c Log: Fixed possible buffer overflow. http://cvs.php.net/diff.php/php-src/ext/standard/iptc.c?r1=1.47r2=1.48ty=u Index: php-src/ext/standard/iptc.c diff -u php-src/ext/standard/iptc.c:1.47 php-src/ext/standard/iptc.c:1.48 --- php-src/ext/standard/iptc.c:1.47Mon Jun 21 18:53:52 2004 +++ php-src/ext/standard/iptc.c Tue Jun 22 16:27:46 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: iptc.c,v 1.47 2004/06/21 22:53:52 iliaa Exp $ */ +/* $Id: iptc.c,v 1.48 2004/06/22 20:27:46 iliaa Exp $ */ /* * Functions to parse compse IPTC data. @@ -351,7 +351,7 @@ inx += 2; } - sprintf(key, %d#%03d, (unsigned int) dataset, (unsigned int) recnum); + snprintf(key, sizeof(key), %d#%03d, (unsigned int) dataset, (unsigned int) recnum); if ((len length) || (inx + len) length) break; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard iptc.c
pajoye Sat Mar 6 12:31:52 2004 EDT Modified files: /php-src/ext/standard iptc.c Log: - fix #27238 http://cvs.php.net/diff.php/php-src/ext/standard/iptc.c?r1=1.45r2=1.46ty=u Index: php-src/ext/standard/iptc.c diff -u php-src/ext/standard/iptc.c:1.45 php-src/ext/standard/iptc.c:1.46 --- php-src/ext/standard/iptc.c:1.45Thu Jan 8 03:17:33 2004 +++ php-src/ext/standard/iptc.c Sat Mar 6 12:31:51 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: iptc.c,v 1.45 2004/01/08 08:17:33 andi Exp $ */ +/* $Id: iptc.c,v 1.46 2004/03/06 17:31:51 pajoye Exp $ */ /* * Functions to parse compse IPTC data. @@ -320,7 +320,7 @@ tagsfound = 0; /* number of tags already found */ while (inx length) { /* find 1st tag */ - if ((buffer[inx] == 0x1c) (buffer[inx+1] == 0x02)){ + if ((buffer[inx] == 0x1c) ((buffer[inx+1] == 0x01) || (buffer[inx+1] == 0x02))){ break; } else { inx++; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php