tony2001 Thu Jan 11 16:45:37 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/pgsql pgsql.c Log: MFH http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.17&r2=1.331.2.13.2.18&diff_format=u Index: php-src/ext/pgsql/pgsql.c diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.17 php-src/ext/pgsql/pgsql.c:1.331.2.13.2.18 --- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.17 Sun Jan 7 04:36:40 2007 +++ php-src/ext/pgsql/pgsql.c Thu Jan 11 16:45:37 2007 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c,v 1.331.2.13.2.17 2007/01/07 04:36:40 iliaa Exp $ */ +/* $Id: pgsql.c,v 1.331.2.13.2.18 2007/01/11 16:45:37 tony2001 Exp $ */ #include <stdlib.h> @@ -3492,10 +3492,11 @@ #if HAVE_PQPUTCOPYDATA while (zend_hash_get_current_data_ex(Z_ARRVAL_P(pg_rows), (void **) &tmp, &pos) == SUCCESS) { convert_to_string_ex(tmp); - query = (char *)emalloc(Z_STRLEN_PP(tmp) +2); - strcpy(query, Z_STRVAL_PP(tmp)); - if(*(query+Z_STRLEN_PP(tmp)-1) != '\n') - strcat(query, "\n"); + query = (char *)emalloc(Z_STRLEN_PP(tmp) + 2); + strlcpy(query, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp) + 2); + if(Z_STRLEN_PP(tmp) > 0 && *(query + Z_STRLEN_PP(tmp) - 1) != '\n') { + strlcat(query, "\n", Z_STRLEN_PP(tmp) + 2); + } if (PQputCopyData(pgsql, query, strlen(query)) != 1) { efree(query); PHP_PQ_ERROR("copy failed: %s", pgsql); @@ -3511,10 +3512,11 @@ #else while (zend_hash_get_current_data_ex(Z_ARRVAL_P(pg_rows), (void **) &tmp, &pos) == SUCCESS) { convert_to_string_ex(tmp); - query = (char *)emalloc(Z_STRLEN_PP(tmp) +2); - strcpy(query, Z_STRVAL_PP(tmp)); - if(*(query+Z_STRLEN_PP(tmp)-1) != '\n') - strcat(query, "\n"); + query = (char *)emalloc(Z_STRLEN_PP(tmp) + 2); + strlcpy(query, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp) + 2); + if(Z_STRLEN_PP(tmp) > 0 && *(query + Z_STRLEN_PP(tmp) - 1) != '\n') { + strlcat(query, "\n", Z_STRLEN_PP(tmp) + 2); + } if (PQputline(pgsql, query)==EOF) { efree(query); PHP_PQ_ERROR("copy failed: %s", pgsql);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php