51 lines
1.5 KiB
Diff
51 lines
1.5 KiB
Diff
Upstream patch for Bug #64565 copy doesn't report failure on partial copy
|
|
https://bugs.php.net/64565
|
|
|
|
Commit in PHP 5.4 branch:
|
|
http://git.php.net/?p=php-src.git;a=patch;h=6b4148bc9705d2668dd8589009215a8eb3076f31
|
|
http://git.php.net/?p=php-src.git;a=patch;h=8e8a75444cbb6bb108e212d48513343fe21c9255
|
|
http://git.php.net/?p=php-src.git;a=patch;h=731a5c51040042a0f344752fee1117701efa3cfd
|
|
|
|
--- php-5.3.3/main/streams/streams.c.copy 2013-04-08 12:50:55.336478801 +0200
|
|
+++ php-5.3.3/main/streams/streams.c 2013-04-08 12:50:55.445479336 +0200
|
|
@@ -1302,7 +1302,7 @@
|
|
char buf[CHUNK_SIZE];
|
|
size_t readchunk;
|
|
size_t haveread = 0;
|
|
- size_t didread;
|
|
+ size_t didread, didwrite, towrite;
|
|
size_t dummy;
|
|
php_stream_statbuf ssbuf;
|
|
|
|
@@ -1337,16 +1337,16 @@
|
|
p = php_stream_mmap_range(src, php_stream_tell(src), maxlen, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped);
|
|
|
|
if (p) {
|
|
- mapped = php_stream_write(dest, p, mapped);
|
|
+ didwrite = php_stream_write(dest, p, mapped);
|
|
|
|
php_stream_mmap_unmap_ex(src, mapped);
|
|
|
|
- *len = mapped;
|
|
+ *len = didwrite;
|
|
|
|
- /* we've got at least 1 byte to read.
|
|
- * less than 1 is an error */
|
|
-
|
|
- if (mapped > 0) {
|
|
+ /* we've got at least 1 byte to read
|
|
+ * less than 1 is an error
|
|
+ * AND read bytes match written */
|
|
+ if (mapped > 0 && mapped == didwrite) {
|
|
return SUCCESS;
|
|
}
|
|
return FAILURE;
|
|
@@ -1364,7 +1364,6 @@
|
|
|
|
if (didread) {
|
|
/* extra paranoid */
|
|
- size_t didwrite, towrite;
|
|
char *writeptr;
|
|
|
|
towrite = didread;
|