summaryrefslogtreecommitdiffstats
path: root/system/libraries/Xmlrpc.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-01-15 16:42:52 +0100
committerAndrey Andreev <narf@devilix.net>2014-01-15 16:42:52 +0100
commitd8b1ad31cf7ee205ddf3cf396b1d1bfa45af49fa (patch)
treec7f9af25914bb61a13aa8df7be69ad73edd74e04 /system/libraries/Xmlrpc.php
parent1b0a6a0c9aaf620d4b45b7392af557e85c6d5339 (diff)
Fix #2822: Incorrect usage of fwrite()
We only used to check (and not always) if the return value of fwrite() is boolean FALSE, while it is possible that the otherwise returned bytecount is less than the length of data that we're trying to write. This allowed incomplete writes over network streams and possibly a few other edge cases.
Diffstat (limited to 'system/libraries/Xmlrpc.php')
-rw-r--r--system/libraries/Xmlrpc.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index 1f93e6981..ab907e706 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -724,7 +724,15 @@ class XML_RPC_Client extends CI_Xmlrpc
.'Content-Length: '.strlen($msg->payload).$r.$r
.$msg->payload;
- if (fwrite($fp, $op, strlen($op)) === FALSE)
+ for ($written = 0, $length = strlen($op); $written < $length; $written += $result)
+ {
+ if (($result = fwrite($fp, substr($op, $written))) === FALSE)
+ {
+ break;
+ }
+ }
+
+ if ($result === FALSE)
{
error_log($this->xmlrpcstr['http_error']);
return new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']);