Skip to content

Commit

Permalink
issue #282: add extra length check (#285)
Browse files Browse the repository at this point in the history
work around short/truncated reads by adding an extra length check rather
than assuming the read string already has a specific length
  • Loading branch information
jsteemann authored Jun 9, 2021
1 parent ec519d4 commit cbd2e44
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/ArangoDBClient/HttpHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ public static function transfer($socket, $request, $method)

// 12 = minimum offset (i.e. strlen("HTTP/1.1 xxx") -
// after that we could see "content-length:"
$pos = stripos($result, 'content-length: ', 12);
$pos = false;
if (strlen($result) > 12) {
$pos = stripos($result, 'content-length: ', 12);
}

if ($pos !== false) {
$contentLength = (int) substr($result, $pos + 16, 10); // 16 = strlen("content-length: ")
Expand Down

0 comments on commit cbd2e44

Please sign in to comment.