Skip to content

Commit 2f9a08b

Browse files
committed
issue #282: add extra length check (#285)
work around short/truncated reads by adding an extra length check rather than assuming the read string already has a specific length
1 parent 2c3e149 commit 2f9a08b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/ArangoDBClient/HttpHelper.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,10 @@ public static function transfer($socket, $request, $method)
255255

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

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

0 commit comments

Comments
 (0)