1 |
vip-ire |
1.1 |
Upstream patch for Bug #64565 copy doesn't report failure on partial copy |
2 |
|
|
https://bugs.php.net/64565 |
3 |
|
|
|
4 |
|
|
Commit in PHP 5.4 branch: |
5 |
|
|
http://git.php.net/?p=php-src.git;a=patch;h=6b4148bc9705d2668dd8589009215a8eb3076f31 |
6 |
|
|
http://git.php.net/?p=php-src.git;a=patch;h=8e8a75444cbb6bb108e212d48513343fe21c9255 |
7 |
|
|
http://git.php.net/?p=php-src.git;a=patch;h=731a5c51040042a0f344752fee1117701efa3cfd |
8 |
|
|
|
9 |
|
|
--- php-5.3.3/main/streams/streams.c.copy 2013-04-08 12:50:55.336478801 +0200 |
10 |
|
|
+++ php-5.3.3/main/streams/streams.c 2013-04-08 12:50:55.445479336 +0200 |
11 |
|
|
@@ -1302,7 +1302,7 @@ |
12 |
|
|
char buf[CHUNK_SIZE]; |
13 |
|
|
size_t readchunk; |
14 |
|
|
size_t haveread = 0; |
15 |
|
|
- size_t didread; |
16 |
|
|
+ size_t didread, didwrite, towrite; |
17 |
|
|
size_t dummy; |
18 |
|
|
php_stream_statbuf ssbuf; |
19 |
|
|
|
20 |
|
|
@@ -1337,16 +1337,16 @@ |
21 |
|
|
p = php_stream_mmap_range(src, php_stream_tell(src), maxlen, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped); |
22 |
|
|
|
23 |
|
|
if (p) { |
24 |
|
|
- mapped = php_stream_write(dest, p, mapped); |
25 |
|
|
+ didwrite = php_stream_write(dest, p, mapped); |
26 |
|
|
|
27 |
|
|
php_stream_mmap_unmap_ex(src, mapped); |
28 |
|
|
|
29 |
|
|
- *len = mapped; |
30 |
|
|
+ *len = didwrite; |
31 |
|
|
|
32 |
|
|
- /* we've got at least 1 byte to read. |
33 |
|
|
- * less than 1 is an error */ |
34 |
|
|
- |
35 |
|
|
- if (mapped > 0) { |
36 |
|
|
+ /* we've got at least 1 byte to read |
37 |
|
|
+ * less than 1 is an error |
38 |
|
|
+ * AND read bytes match written */ |
39 |
|
|
+ if (mapped > 0 && mapped == didwrite) { |
40 |
|
|
return SUCCESS; |
41 |
|
|
} |
42 |
|
|
return FAILURE; |
43 |
|
|
@@ -1364,7 +1364,6 @@ |
44 |
|
|
|
45 |
|
|
if (didread) { |
46 |
|
|
/* extra paranoid */ |
47 |
|
|
- size_t didwrite, towrite; |
48 |
|
|
char *writeptr; |
49 |
|
|
|
50 |
|
|
towrite = didread; |