com php-src: Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport: ext/pgsql /pgsql.c ext/standard/file.c
ext/standard/streamsfuncs .c

From: Date: Wed, 02 Jul 2014 08:22:09 +0000
Subject: com php-src: Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport: ext/pgsql /pgsql.c ext/standard/file.c
ext/standard/streamsfuncs .c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-79182@lists.php.net to get a copy of this message
Commit: 96783bdfb79b33646dc916d4b93bc33b78d70c4c Author: Anatol Belski <ab@php.net> Wed, 2 Jul 2014 10:22:09 +0200 Parents: 1a50c27f998769c5b3472d35c39852286900db69 122ee0a1cf2b31ae2497fada3900848382fbfb70 Branches: str_size_and_int64_56_backport Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=96783bdfb79b33646dc916d4b93bc33b78d70c4c Log: Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport * origin/PHP-5.6: fix integer overflow in {stream,file}_{get,put}_contents() add some missing NEWS entries NEWS block for 5.6.0RC3 Fix ext/pgsql builds with libpq < 7.3. updated libs_version.txt updated libs_version.txt updated libmagic.patch in 5.6+ updated libmagic.patch Conflicts: ext/standard/file.c ext/standard/streamsfuncs.c Changed paths: MM ext/pgsql/pgsql.c MM ext/standard/file.c MM ext/standard/streamsfuncs.c Diff: diff --cc ext/standard/file.c index 85753e1,10ed693..3168577 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@@ -625,14 -628,16 +629,18 @@@ PHP_FUNCTION(file_put_contents php_stream_truncate_set_size(stream, 0); } + /* In case of php_stream_write() it returns size_t, so we only can check if the full data was written. + XXX maybe the write should be retried once more */ switch (Z_TYPE_P(data)) { case IS_RESOURCE: { - size_t len; + php_size_t len; if (php_stream_copy_to_stream_ex(srcstream, stream, PHP_STREAM_COPY_ALL, &len) != SUCCESS) { - numbytes = -1; + ret_ok = 0; } else { - if (len > LONG_MAX) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "content truncated from %lu to %ld bytes", (unsigned long) len, LONG_MAX); - len = LONG_MAX; ++ if (len > PHP_INT_MAX) { ++ php_error_docref(NULL TSRMLS_CC, E_WARNING, "content truncated from %zd to %pd bytes", len, PHP_INT_MAX); ++ len = PHP_INT_MAX; + } numbytes = len; } break; @@@ -645,11 -650,11 +653,11 @@@ convert_to_string_ex(&data); case IS_STRING: - if (Z_STRLEN_P(data)) { - numbytes = php_stream_write(stream, Z_STRVAL_P(data), Z_STRLEN_P(data)); - if (numbytes != Z_STRLEN_P(data)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %ld of %d bytes written, possibly out of free disk space", numbytes, Z_STRLEN_P(data)); - numbytes = -1; + if (Z_STRSIZE_P(data)) { + numbytes = php_stream_write(stream, Z_STRVAL_P(data), Z_STRSIZE_P(data)); + if (numbytes != Z_STRSIZE_P(data)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d bytes written, possibly out of free disk space", numbytes, Z_STRSIZE_P(data)); ++ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %zd of %zd bytes written, possibly out of free disk space", numbytes, Z_STRSIZE_P(data)); + ret_ok = 0; } } break; @@@ -665,14 -671,16 +673,14 @@@ SEPARATE_ZVAL(tmp); convert_to_string(*tmp); } - if (Z_STRLEN_PP(tmp)) { - numbytes += Z_STRLEN_PP(tmp); - bytes_written = php_stream_write(stream, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); - if (bytes_written < 0 || bytes_written != Z_STRLEN_PP(tmp)) { - if (bytes_written < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write %d bytes to %s", Z_STRLEN_PP(tmp), filename); - } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d bytes written, possibly out of free disk space", bytes_written, Z_STRLEN_PP(tmp)); - } - numbytes = -1; + if (Z_STRSIZE_PP(tmp)) { + php_size_t bytes_written; + + numbytes += Z_STRSIZE_PP(tmp); + bytes_written = php_stream_write(stream, Z_STRVAL_PP(tmp), Z_STRSIZE_PP(tmp)); + if (bytes_written != Z_STRSIZE_PP(tmp)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write %d bytes to %s", Z_STRSIZE_PP(tmp), filename); ++ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write %zd bytes to %s", Z_STRSIZE_PP(tmp), filename); + ret_ok = 0; break; } } @@@ -686,10 -694,10 +694,10 @@@ zval out; if (zend_std_cast_object_tostring(data, &out, IS_STRING TSRMLS_CC) == SUCCESS) { - numbytes = php_stream_write(stream, Z_STRVAL(out), Z_STRLEN(out)); - if (numbytes != Z_STRLEN(out)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %ld of %d bytes written, possibly out of free disk space", numbytes, Z_STRLEN(out)); - numbytes = -1; + numbytes = php_stream_write(stream, Z_STRVAL(out), Z_STRSIZE(out)); + if (numbytes != Z_STRSIZE(out)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d bytes written, possibly out of free disk space", numbytes, Z_STRSIZE(out)); ++ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %zd of %zd bytes written, possibly out of free disk space", numbytes, Z_STRSIZE(out)); + ret_ok = 0; } zval_dtor(&out); break;

« previous php.cvs (#79182) next »